Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?

前端 未结 2 2021
感动是毒
感动是毒 2020-12-24 03:04

I\'m creating a CAShapeLayer to use as a mask for a UIView\'s layer. I\'m using a UIBezierPath to draw the shape layer. It\'s working

2条回答
  •  悲&欢浪女
    2020-12-24 03:10

    Have a look at Figure 1 in the bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise: documentation: For a "pie slice" in the upper right corner you have to use the parameters

    startAngle:degreesToRadians(-90) endAngle:0 clockwise:YES
    

    (The reason is that the default coordinate system on iOS has a x-axis pointing to the right, and a y-axis pointing down.)

提交回复
热议问题