質問

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);
役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top