start and end angle of UIBezierPath?

前端 未结 3 1487
遇见更好的自我
遇见更好的自我 2021-02-07 23:36

I have coded as below for half circle in iOS using UIBezierPath and CAShapeLayer.

 clockWiseLayer = [[CAShapeLayer alloc] init]         


        
3条回答
  •  后悔当初
    2021-02-08 00:11

    You start from top of the circle with -M_PI_2 and end at M_PI + M_PI_2 (if you want to have full circle and limit it using strokeEnd, strokeStart). Then set the circle path to draw from half of the end of the path (left side of image) instead from beginning to half (right side of the image)

    CGFloat startAngle = -M_PI_2;
    CGFloat endAngle = M_PI + M_PI_2;
    
    clockWiseLayer.strokeStart = .5f;
    clockWiseLayer.strokeEnd = 1.0f;
    

提交回复
热议问题