UIBezierPath - 添加圆角

UIBezierPath - Add rounded corner

我正在使用 UIBezierPath 绘制曲线。但是曲线有效,我无法弯曲线的边缘。

如果您查看曲线的 top/bottom 端,您会发现边缘变平了,这不是我想要的。有没有办法让边缘弯曲?

我正在使用一个简单的 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 属性,但拐角没有弯曲。我做错了什么?

丹,谢谢你的时间。

包括以下内容。

circle.lineCap = kCALineJoinRound;

对于 Swift 3.0 及更高版本

circle.lineCapStyle = .Round;

Swift 4.0

circle.lineCap = kCALineCapRound

如果你希望你的线交叉点也被设置为圆形

circle.lineJoin = kCALineCapRound

还有。