问题描述
let circleLayer = CAShapeLayer()
circleLayer.path = UIBezierPath(arcCenter: CGPoint(x: frame.size.width / 2,y: frame.size.height / 2),radius: frame.size.width / 2,startAngle: -.pi / 2,endAngle: .pi / 6,clockwise: false).cgPath
circleLayer.linewidth = 8.0
circleLayer.cornerRadius = 4.0
circleLayer.strokeColor = UIColor.black.cgColor
circleLayer.fillColor = UIColor.clear.cgColor
circleLayer.lineJoin = .round
squareView.layer.backgroundColor = UIColor.clear.cgColor
squareView.layer.addSublayer(circleLayer)
我得到的结果:
但是,我想得到这个结果:
你能帮我得到这个吗?
感谢您的帮助!
解决方法
要使您的线帽变圆,只需告诉您的形状图层使用圆形线帽:
circleLayer.lineCap = .round