我正在使用 UIBezierPath
绘制一条曲线。但是曲线有效,我无法弯曲线的边缘。
如果您查看曲线的顶端/底端,您会发现边缘变平了,这不是我想要的。有没有办法使边缘弯曲?
我正在使用一个简单的 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;
关于ios - UIBezierPath - 添加圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42223186/