Detect animation completion

So,

I am doing a simple animation with CABasicAnimation(as shown below).

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

Is there any method, for example -(BOOL) isAnimationCompleted;, so that I can know when the animation is complete?

I want to run the method immediately after the animation is complete. Any ideas?

+5
source share
2 answers

Implement method

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

which you can see in the document here .

+9
source

I use the category to create this method:

[group setCompletionBlock:^{

}];

See my answer here: fooobar.com/questions/1097606 / ...

0
source

All Articles