绘制代码:
UIBezierPath * halfCirclePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(centerX, centerY) radius:[self radius] startAngle:[self radiusOfDegress:self.startValue] endAngle:[self radiusOfDegress:self.endValue] clockwise:YES];
self.path = halfCirclePath.CGPath;
self.fillColor = [UIColor yellowColor].CGColor;
self.strokeColor = [UIColor blackColor].CGColor;
self.lineWidth = 10;
self.lineCap = kCALineCapRound;
动画代码:
CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
bas.duration = 2;
bas.fromValue = @(0);
bas.toValue = @(1);
bas.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.halfLayer addAnimation:bas forKey:nil];