如何获得CATransition / Animation的结束事件?

时间:2011-01-30 04:18:16

标签: iphone

我的代码如下所示:

CATransition *transition = [CATransition animation];
transition.duration = duration 

我希望得到CATransition / Animation的结束事件。有可能吗?

1 个答案:

答案 0 :(得分:26)

CAAnimation(CATransition是其子类)具有您可以使用的委托方法animationDidStop:finished:

设置委托属性并实现方法:

CATransition *transition = [CATransition animation];
transition.duration = duration;
transition.delegate = self;
//other settings...
//call addAnimation...

...

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
    //do what you need to do when animation ends...
}