Начало и конец строки для круга с UIBezierPath - PullRequest
1 голос
/ 09 мая 2020

У меня есть случай, очень похожий на Рисование круга с помощью UIBezierPath У меня это path с UIBezierPath

enter image description here

Просто сфокусируйтесь на сером круге:

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()

Я пытаюсь изменить начало и конец изогнутой серой линии и сделать закругленное начало / конец, например:

enter image description here

Может мне кто-нибудь помочь?

1 Ответ

0 голосов
/ 09 мая 2020

Установите lineCap слоя-фигуры на .round.

...