所以我想創建一個圓的一部分,即扇形餅,然後用一個圓圈去除大部分的楔子留下一個外部弧。appendPath產生空心物體核心圖形
這就是我到目前爲止 正如你可以看到它正在搞亂某個地方!
我實現這個使用下面的代碼: -
UIBezierPath* theStroke = [UIBezierPath bezierPathWithRoundedRect:mainCutout cornerRadius:theRadius];
[theOrangeColor setFill];
theStroke.usesEvenOddFillRule = YES;
[theStroke fill];
[theStroke stroke];
[theStroke setMiterLimit:2.0];
UIBezierPath *aSegment = [UIBezierPath bezierPath];
aSegment.usesEvenOddFillRule = YES;
[aSegment moveToPoint:theCenter];
[aSegment addLineToPoint:theCenter];
[aSegment addArcWithCenter:theCenter radius:theRadius startAngle:startAngle endAngle:endAngle clockwise:YES];
[aSegment addLineToPoint:theCenter];
[aSegment appendPath:theStroke];
[theRedColor setFill];
[aSegment fill];
[aSegment stroke];
[aSegment closePath];
誰能幫助我?
謝謝!超級複雜的這樣一個簡單的問題! –
@WillRoberts:不客氣! –
這個利用的一個事實是'addArcWithCenter:radius:startAngle:endAngle:順時針:'和其他類似於UIBezierPath和Cocoa表兄弟(以及類似Quartz中的函數)的方法,將會隱含地從你上一個當前點開始的「lineto」。從該代碼看來,如果沒有當前點,它甚至會隱式「移動」弧的起點。繪製的弧線的一端是這樣一個隱含的線段(在兩條弧線之間);另一個由'closePath'提供,返回到第一個弧的起始點。 –