我有一些從Web服務中獲取的百分比值。根據百分比值,我想通過以下方式在UIView
中畫出一些弧線。如何在swift中繪製弧線3
白色圓圈是UIView
,我用這種方式試圖實現這一目標。
func colorProgress()
{
let circleColorPath=UIBezierPath(arcCenter: CGPoint.init(x: RDcircleEnum.circleCenterX.getValues(), y: RDcircleEnum.circleCenterY.getValues()), radius: self.innerCircleRadius, startAngle: CGFloat(0), endAngle: CGFloat(Double.pi*self.progressAmount), clockwise: true)
let shapeLayer = CAShapeLayer()
shapeLayer.path = circleColorPath.cgPath
//change the fill color
shapeLayer.fillColor = UIColor.blue.cgColor
//you can change the stroke color
shapeLayer.strokeColor = UIColor.red.cgColor
//you can change the line width
shapeLayer.lineWidth = 3.0
self.progressColor.setFill()
circleColorPath.fill()
}
但是這並沒有給我想要的。我想根據百分比值繪製不同長度的弧線。請幫幫我。
入住這https://github.com/darrarski/DRCircularProgress-iOS –