0

我正在尝试制作一个将被动画并顺时针填充黑色的圆圈,圆圈动画的持续时间预定义为 20 秒,我想要做的是前 10 秒它将被黑色填充,其余的圆圈将被红色填充,总共 20 秒后它将变成一个 2 色的圆形圆圈,但我找不到它的任何过程,这是我绘制圆圈动画的代码:

-(void)makeCircle{
int radius = 100;
CAShapeLayer *circle = [CAShapeLayer layer];
//make a circular shape
circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius)cornerRadius:radius].CGPath;
//centre the shape in self.view
circle.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius, CGRectGetMidY(self.view.frame)-radius);
//configure the appearence of the circle
circle.fillColor = [UIColor clearColor].CGColor;

circle.strokeColor =[UIColor blackColor].CGColor;
circle.lineWidth = 5;

//add to parent layer
[self.view.layer addSublayer:circle];

//configure animation
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration = 20.0;//animate over 10 seconds or so...
drawAnimation.repeatCount=1.0;//animate only once;

drawAnimation.removedOnCompletion=NO;

drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue = [NSNumber numberWithFloat:1.0f];

drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[circle addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
}

但我需要知道我该怎么做?

4

1 回答 1

0

你看过这个吗?

我认为这可能会有所帮助。

于 2012-12-30T16:27:41.320 回答