使用 UIBezierPath 的圆形线的开始和结束

Round start and end of the line for a circle with UIBezierPath

我有一个案例与Draw circle with UIBezierPath非常相似 我有这个 pathUIBezierPath

只关注灰色圆圈:

grayView = UIView(frame: CGRect(x: screenWidth * 0.15,
                                        y: 150,
                                        width: screenWidth * 0.7,
                                        height: screenWidth * 0.7 ))

        let layer = CAShapeLayer()
        layer.strokeColor = UIColor.gray.cgColor
        layer.fillColor = UIColor.clear.cgColor
        layer.lineWidth = 32

        let path = UIBezierPath()
        path.addCircle(center: CGPoint(x: grayView.bounds.width / 2,
                                       y: grayView.bounds.height / 2),
                                        radius: screenWidth/3.5,
                                        startAngle: 125,
                                        circlePercentage: 0.8)

        layer.path = path.cgPath

        grayView.layer.addSublayer(layer)
        grayView.setNeedsLayout()

我想要做的是修改灰色曲线的起点和终点并制作一个圆角 start/end,如下所示:

有人可以帮助我吗?

设置 lineCap of the shape layer to .round.