CAShapeLayer strokeStart和strokeEnd position

gas*_*uff 5 cashapelayer ios swift

我有这段代码:

    let arcPath = UIBezierPath(ovalInRect: CGRectMake(0, 0, frame.width, frame.height))

    circleLayer = CAShapeLayer()
    circleLayer.path = arcPath.CGPath
    circleLayer.fillColor = UIColor.clearColor().CGColor
    circleLayer.strokeColor = UIColor.blueColor().CGColor
    circleLayer.lineWidth = 5.0;

    circleLayer.strokeStart = 0
    circleLayer.strokeEnd = 0.7
Run Code Online (Sandbox Code Playgroud)

结果如下:

在此输入图像描述

如您所见,圆弧从圆的右侧开始.我想从顶部开始画弧.我该怎么办?我是否必须将整个事物旋转-90度才能完成我想要做的事情?

谢谢.

Leo*_*Leo 13

您可以像这样创建路径

let bezierPath = UIBezierPath(arcCenter:CGPointMake(100,100), radius:40, startAngle: CGFloat(M_PI_2) * 3.0, endAngle:CGFloat(M_PI_2) * 3.0 + CGFloat(M_PI) * 2.0, clockwise: true)
Run Code Online (Sandbox Code Playgroud)

SceenShot