【发布时间】:2016-01-28 00:45:23
【问题描述】:
【问题讨论】:
标签: ios objective-c xcode uiview
【问题讨论】:
标签: ios objective-c xcode uiview
// To draw an arc path
func drawCircle(view: UIView, startingAngle: CGFloat, endAngle: CGFloat) -> CAShapeLayer {
let path = UIBezierPath(arcCenter: CGPoint(x:arcViewOutlet.frame.size.width/2,y:400), radius: CGFloat((400)), startAngle: startingAngle, endAngle:endAngle, clockwise: true)
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.strokeColor = UIColor.clear.cgColor
shapeLayer.fillColor = UIColor.white.cgColor
shapeLayer.lineCap = kCALineCapRound
view.layer.addSublayer(shapeLayer)
return shapeLayer
}
根据我的要求,我使用半径为 400。
如下给出 arcCentres。
CGPoint(x:arcViewOutlet.frame.size.width/2,y:400) //for top edge curve
CGPoint(x:arcViewOutlet.frame.size.width/2,y:-400) //for bottom edge curve
CGPoint(x:400,y:arcViewOutlet.frame.size.height/2) //for left edge curve
CGPoint(x:-400,y:arcViewOutlet.frame.size.height/2) //for right edge curve
【讨论】:
您可以使用CAShapeLayer 作为UIView 的子层或支持层。 CAShapeLayer 允许您设置路径、描边、填充等。
【讨论】: