2017-02-14 80 views
5

我正在使用UIBezierPath繪製曲線。但曲線起作用,我無法曲線的邊緣。UIBezierPath - 添加圓角

enter image description here

如果你看一下曲線的頂部/底部結束,你可以看到,邊緣變平了,那不是我想要的。有沒有辦法曲線的邊緣?

我正在使用簡單的UIBezierPath繪製(幾乎)半圓。這將創建一個我想要的曲線形狀:

CAShapeLayer *circle = [CAShapeLayer layer]; 
circle.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0, 0) radius:70 startAngle:1.0472 endAngle:5.23599 clockwise:NO].CGPath; 
circle.fillColor = [UIColor clearColor].CGColor; 
circle.strokeColor = [UIColor colorWithWhite:1.0 alpha:0.2].CGColor; 
circle.lineWidth = 18.0; 
circle.cornerRadius = 10.0; 
circle.position = CGPointMake(100, 100); 
circle.anchorPoint = CGPointMake(0.5, 0.5); 
[mainView.layer addSublayer:circle]; 

儘管設置cornerRadius財產,邊角都沒有彎曲。我究竟做錯了什麼?

謝謝你的時間,丹。

回答

7

包括以下內容。

circle.lineCap = kCALineJoinRound; 

對於雨燕3.0

circle.lineCapStyle = .Round; 
+0

完美的作品,謝謝! – Supertecnoboff

1

雨燕4.0

circle.lineCap = kCALineCapRound 

,如果你也想被你的圓潤線條交叉設置

circle.lineJoin = kCALineCapRound