我有这段代码:

    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

结果如下:

ios - CAShapeLayer strokeStart和strokeEnd位置-LMLPHP

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

谢谢。

最佳答案

您可以像这样创建路径

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)
截屏

关于ios - CAShapeLayer strokeStart和strokeEnd位置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33431210/

10-12 06:25