11
A
回答
23
有很多方法可以做到這一點,但一個是剛剛得出兩個貝塞爾路徑,每側一個:
- (void)drawRect:(CGRect)rect
{
UIBezierPath *blueHalf = [UIBezierPath bezierPath];
[blueHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES];
[blueHalf setLineWidth:4.0];
[[UIColor blueColor] setStroke];
[blueHalf stroke];
UIBezierPath *redHalf = [UIBezierPath bezierPath];
[redHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:M_PI_2 endAngle:-M_PI_2 clockwise:YES];
[redHalf setLineWidth:4.0];
[[UIColor redColor] setStroke];
[redHalf stroke];
}
或者,如果你想這樣做核芯顯卡:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 4);
CGContextSetStrokeColorWithColor(context, [[UIColor blueColor] CGColor]);
CGContextAddArc(context, 100, 100, 90, -M_PI_2, M_PI_2, FALSE);
CGContextStrokePath(context);
CGContextSetStrokeColorWithColor(context, [[UIColor redColor] CGColor]);
CGContextAddArc(context, 100, 100, 90, M_PI_2, -M_PI_2, FALSE);
CGContextStrokePath(context);
}
相關問題
- 1. 不完整的UIBezierPath筆畫
- 2. HTML5畫布 - 不同的筆畫
- 3. 在iOS中畫圓圈動畫用圓形筆畫
- 4. 圓形筆畫的筆畫動畫以完整筆畫結尾
- 5. UIBezierPath筆畫1px線和填充1px寬度的矩形 - 不同的結果。
- 6. 如何動畫UIBezierPath
- 7. UIBezierPath脈衝動畫
- 8. 畫上一個UIBezierPath
- 9. UIBezierPath - 動畫填寫
- 10. 如何更改UIBezierPath筆畫的顏色並設置動畫效果?
- 11. 手指畫筆中的筆畫刪除
- 12. c#同時畫很多圈
- 13. 保持以前的UIBezierPath筆畫在連續調用drawRect
- 14. 動畫顏色屬性有不同的畫筆
- 15. iOS - 只動畫UIBezierPath的'appendPath'
- 16. UIView中的UIBezierPath動畫
- 17. HTML5畫筆筆尖
- 18. 多邊形SVG不同筆畫
- 19. 用不同顏色撤銷筆畫
- 20. d3畫筆部分更新座標軸不是圓圈
- 21. 在inkpresenter中動畫筆畫
- 22. SVG圈動畫
- 23. MFC畫圈
- 24. .net筆畫與筆(不同的顏色)在一個循環中
- 25. jQuery的動畫圈
- 26. 畫布上畫的畫筆不起作用
- 27. HTML5畫布畫圈圈繞一大圈路
- 28. Quake MAP畫筆
- 29. 繪製畫筆
- 30. HTML5 JavaScript畫筆
使用具有不同顏色的「UIBezierPath」繪製兩個單獨的弧線。 – Exploring
是的,你可以做兩個或兩個以上的弧線,這取決於你需要的顏色數量。 – CodenameLambda1