문제

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