我在 UIView 的 drawRect 函数中添加了以下代码,创建了以下附加的绿色弧线。
有没有办法让曲线末端的边缘看起来像所附较小图像中的红色圆弧圆边。
[![//Draw the Interior
let center = CGPoint(x: bounds.width/2,
y: bounds.height/2)
//Calculate the radius based on the max dimension of the view.
let radius = max(bounds.width, bounds.height)
//Thickness of the Arc
let arcWidth: CGFloat = 76
//Start and End of Circle angle
let startAngle: CGFloat = 3 * π/4
let endAngle: CGFloat = π/4
let path = UIBezierPath(arcCenter: center, radius: radius/2 - arcWidth/2,
startAngle: startAngle,
endAngle: endAngle,
clockwise: true)
path.lineWidth = arcWidth
counterColor.setStroke()
path.stroke()]
最佳答案
设置lineCapStyle
贝塞尔路径的属性
.Round
:
A line with a rounded end. Quartz draws the line to extend beyond the endpoint of the path. The line ends with a semicircular arc with a radius of 1/2 the line’s width, centered on the endpoint.
path.lineCapStyle = .Round
关于ios - 将曲线添加到 UIBezierPath(arcCentre) 的末端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33276463/