在 swift 中圆化贝塞尔路径圆中的笔画边缘

Rounding the edges of a stroke in bezier path circle in swift

我正在尝试使用 UIBezierPath(ovalInRect: CGRectMake()) 画一个圆。那我就改成strokeEnd属性。发生这种情况时,圆线的两端都有尖角。有没有办法把这些角弄圆?

(我想把这条线的起点和终点做成曲线)

假设您使用 CAShapeLayer 来绘制这个,只需设置 lineCap,例如:

layer.lineCap = .round

对于基于 drawRect 的解决方案,使用 lineCapStyle

let path = UIBezierPath(...) path.lineCapStyle = .round