0
我正在使用下面的代码来为一个圆圈设置动画。它不断闪烁,我想延迟动画重启,让我们说5秒。我怎样才能做到这一点?延迟动画iphon
-(void)start
{
[self removeExistingAnimation];
//create the image
UIImage* img = [UIImage imageNamed:@"redCircle.png"];
imageView = [[UIImageView alloc] initWithImage:img];
imageView.frame = CGRectMake(0, 0, 0, 0);
[self addSubview:imageView];
//opacity animation setup
CABasicAnimation *opacityAnimation;
opacityAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.duration = ANIMATION_DURATION;
opacityAnimation.repeatCount = ANIMATION_REPEAT;
//theAnimation.autoreverses=YES;
opacityAnimation.fromValue = [NSNumber numberWithFloat:0.6];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.025];
//resize animation setup
CABasicAnimation *transformAnimation;
transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
transformAnimation.duration = ANIMATION_DURATION;
transformAnimation.repeatCount = ANIMATION_REPEAT;
//transformAnimation.autoreverses=YES;
transformAnimation.fromValue = [NSNumber numberWithFloat:MIN_RATIO];
transformAnimation.toValue = [NSNumber numberWithFloat:MAX_RATIO];
//group the two animation
CAAnimationGroup *group = [CAAnimationGroup animation];
group.repeatCount = ANIMATION_REPEAT;
[group setAnimations:[NSArray arrayWithObjects:opacityAnimation, transformAnimation, nil]];
group.duration = ANIMATION_DURATION;
//apply the grouped animaton
[imageView.layer addAnimation:group forKey:@"groupAnimation"];
}
不起作用。亲自尝试一下 – 2013-02-18 15:57:08
@MuhammadUmar你用这个动画制作了哪个框架? – Dilip 2013-02-18 16:00:18
QuartzCore。它工作,如果我删除opacityAnimation.duration = ANIMATION_DURATION;和其他动画持续时间,但动画停止时仍然存在一个错误,imageView仍然添加到自我中,我可以看到大红圈。我想删除这个圈子,像atEndAnimation调用函数removeExistingAnimation – 2013-02-18 16:03:41