overridefuncdraw(_rect:CGRect) {
// let color1 = UIColor.white
// color1.set() // 设置线条颜色
letaPath1 =UIBezierPath(arcCenter:CGPoint(x:80, y:80), radius:74,
startAngle:(CGFloat)((90*3)*Double.pi/180), endAngle: (CGFloat)(1.25*Double.pi), clockwise:true)
// aPath1.setLineDash([3.0,70*CGFloat(Double.pi/80)-0.1 - 2], count:1, phase: 0)
// aPath1.lineWidth = 8.0 // 线条宽度
// aPath1.stroke() // Draws line 根据坐标点连线,不填充
//添加动画
letlineShape =CAShapeLayer()
lineShape.frame=CGRect.init(x:0, y:0, width:74, height:74)
lineShape.lineWidth=8
lineShape.strokeColor=UIColor.white.cgColor
lineShape.path= aPath1.cgPath
lineShape.fillColor=UIColor.clear.cgColor
lineShape.lineDashPhase=1
letarr :NSArray=NSArray(array: [3.0,70*CGFloat(Double.pi/80)-0.1-2])
lineShape.lineDashPattern= arras? [NSNumber]
self.layer.addSublayer(lineShape)
aPath1.close()
// let color = UIColor(rgba: "#5999F9")
// color.set() // 设置线条颜色
letaPath =UIBezierPath(arcCenter:CGPoint(x:80, y:80), radius:74,
startAngle:(CGFloat)(1.25*Double.pi)+(CGFloat)(2*Double.pi/180), endAngle: (CGFloat)((90*3)*Double.pi/180)-(CGFloat)(2*Double.pi/180), clockwise:true)
// aPath.setLineDash([3.0,70*CGFloat(Double.pi/80)-0.1 - 2], count:1, phase: 0)
// aPath.lineWidth = 8.0 // 线条宽度
// aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
//添加动画
letlineShape1 =CAShapeLayer()
lineShape1.frame=CGRect.init(x:0, y:0, width:74, height:74)
lineShape1.lineWidth=8
lineShape1.strokeColor=UIColor(red:51/250.0, green:51/250.0, blue:51/250.0, alpha:0.5).cgColor
lineShape1.path= aPath.cgPath
lineShape1.fillColor=UIColor.clear.cgColor
lineShape1.lineDashPattern= arras? [NSNumber]
self.layer.addSublayer(lineShape1)
//添加动画
letpathAnimation1 =CABasicAnimation.init(keyPath:"strokeEnd")
pathAnimation1.duration=1
pathAnimation1.timingFunction = CAMediaTimingFunction.init(name: CAMediaTimingFunctionName.easeOut)
pathAnimation1.fromValue=0
pathAnimation1.toValue=1
lineShape1.add(pathAnimation1, forKey:"strokeEndAnimation")
lineShape.add(pathAnimation1, forKey:"strokeEndAnimation")
aPath.close()
}
网友评论