Pregunta

How can I draw a perfect donut with inner and outer radius with a CAShapeLayer?

Or better to ask: How to draw a Circle with a hole in it, so that the stroke is two seperate lines. One on the inner and one on the outer circle. All I've achieved so far is that the stroke of the inner and outer circle is connected, which I want to avoid:

    CGPathAddArc( _path, NULL, _center.x, _center.y, 100, 0, M_PI * 2.0f, NO);
    CGPathRef temp = CGPathCreateCopyByStrokingPath(_path, &_transform, 10, kCGLineCapButt, kCGLineJoinMiter, 10);

    _path = CGPathCreateMutableCopy(temp);
¿Fue útil?

Solución

You can create a path that has two circles (the outer and the inner radius) added to it. Then you can set the fillMode of the shape layer to kCAFillRuleEvenOdd.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top