检测动画的完成情况

时间:2011-12-28 11:34:59

标签: iphone objective-c cocoa-touch animation core-animation

所以,

我使用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;这样的方法,以便我可以知道动画何时完成?

我想在动画完全结束后立即运行一个方法。有什么想法吗?

2 个答案:

答案 0 :(得分:9)

实施方法

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

您可以在here看到该文档。

答案 1 :(得分:0)

我使用类别来创建这样的方法:

[group setCompletionBlock:^{

}];

请在此处查看我的回答:https://stackoverflow.com/a/28051909/1485701