2011-12-28 95 views
5

所以,检测动画的完成

我用CABasicAnimation(如下图所示)执行一个简单的动画。

CAAnimationGroup *theGroup = [CAAnimationGroup animation]; 
theGroup.fillMode = kCAFillModeForwards; 
theGroup.removedOnCompletion = NO; 
theGroup.delegate = self; 
theGroup.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 

theGroup.duration = inDuration; 
theGroup.repeatCount = 0; 
theGroup.animations = [NSArray arrayWithObjects:rotationZ, theAnimationX, theAnimationY, nil]; // you can add more 

[inLayer addAnimation:theGroup forKey:@"animateLayer"]; 

NSLog (@"ABCD"); 
// This gets called before end of animation 

有没有像-(BOOL) isAnimationCompleted;所以任何方法完成动画的时候才能知道?

我想在动画完成后立即运行一个方法。有任何想法吗 ?

回答

9

实现该方法

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag 

你可以从here看到该文档。

+0

此方法不返回任何东西。 – Legolas 2011-12-28 11:56:27

+1

是的,它的返回类型是'void'。但您会被告知动画已通过此代表方法完成。然后,你可以在这里调用所需的方法。 – Ilanchezhian 2011-12-28 11:59:33

+0

美丽。谢谢 ! – Legolas 2011-12-28 12:04:50