【问题标题】:Round start and end of the line for a circle with UIBezierPath使用 UIBezierPath 对圆进行圆的开始和结束
【发布时间】:2020-05-08 21:58:50
【问题描述】:

我有一个与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()

我要做的是修改弯曲灰线的起点和终点,并制作一个圆形的起点/终点,如下所示:

有人可以帮我吗?

【问题讨论】:

    标签: swift uibezierpath swift5


    【解决方案1】:

    将形状图层的lineCap设置为.round

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-02
      • 2017-09-12
      • 1970-01-01
      • 2019-03-14
      相关资源
      最近更新 更多