I have an animation that works perfectly on the first invocation. But if I want to animate the very same layer again, using the same code, it completes immediately and the animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
is invoked on the delegate with the flag
value NO
.
Here is the code that adds the animation:
imageView.hidden = NO;
CAKeyframeAnimation* animationOpacity =
[CAKeyframeAnimation animationWithKeyPath:@"opacity"];
...
animationOpacity.duration = 2.0;
animationOpacity.removedOnCompletion = YES;
animationOpacity.delegate = self;
[imageView.layer addAnimation:animationOpacity forKey:@"someKey"];
and this is the delegate action:
-(void) animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
imageView.hidden = YES;
}
BTW, Initially the imageView
is visible in the XIB.