首先创建一个圆形的shaperlayer
circleLayer = [CAShapeLayer
layer];
circleLayer.frame =
CGRectMake(100,
120, 64, 64);
circleLayer.backgroundColor = [UIColor
clearColor].CGColor
;
circleLayer.fillColor = [UIColor
greenColor].CGColor;
circleLayer.lineWidth =
2;
circleLayer.lineCap =
kCALineCapRound;
circleLayer.strokeStart =
0.0;
circleLayer.strokeEnd =
1.0;
UIBezierPath *path = [UIBezierPath
bezierPathWithArcCenter:CGPointMake(32,
32)
radius:30
startAngle:4.0/10*M_PI
endAngle:6.0/10*M_PI
clockwise:YES];
circleLayer.path = path.CGPath;
[self.view.layer
addSublayer:circleLayer];
使用定时器填充,实际上是逐渐扩大圆形的角度
-(void) fill
{
startEngle -=
1;
endEngle += 1;
UIBezierPath *path = [UIBezierPath
bezierPathWithArcCenter:CGPointMake(32,
32)
radius:30
startAngle:startEngle/10*
M_PI
endAngle:endEngle/10*M_PI
clockwise:YES];
circleLayer.path = path.CGPath;
if (endEngle -
startEngle >= 20)
{
[timer
setFireDate:[NSDate
distantFuture]];
}
}