2011-12-28 94 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