【发布时间】:2018-03-07 05:23:36
【问题描述】:
我有一些来自网络服务的百分比值。根据百分比值我想在UIView下面画一些弧线。
白色圆圈是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()
}
但这并没有给出我想要的。我想根据百分比值绘制不同长度的弧线。请帮帮我。
【问题讨论】: