1

当 viewWillAppear 或 viewDidAppear 被调用时,如何让我的动画再次运行?

这是我的动画:

bounceAnimation =[CABasicAnimation animationWithKeyPath:@"transform.scale"];
[bounceAnimation setToValue:[NSNumber numberWithFloat:1.4f]];
bounceAnimation.duration = 1;
bounceAnimation.repeatCount = 100000;
bounceAnimation.autoreverses = YES;
bounceAnimation.fillMode =kCAMediaTimingFunctionEaseInEaseOut;
bounceAnimation.removedOnCompletion = YES;
[startBtn.layer addAnimation:bounceAnimation forKey:@"bounceAnimation"];
4

1 回答 1

1

你是如何调用你的动画的?

目前,我想你也可以

1) 将上述代码放入一个方法中,然后再次从 viewDidAppear 调用该方法。

2)或者,也许更好...将您的动画的 removedOnCompletion 属性设置为 NO 通过

bounceAnimation.removedOnCompletion = NO;

当您准备好再次运行它时,调用您之前添加的相同(保留)动画。

于 2011-10-23T17:20:55.897 回答