I am updating the contents of a CALayer using the following code:
CAKeyframeAnimation *countanimation = [CAKeyframeAnimation animation]; NSArray *images = [NSArray arrayWithObjects:(id)[UIImage imageNamed:@"number3"].CGImage, (id)[UIImage imageNamed:@"number2"].CGImage, (id)[UIImage imageNamed:@"number1"].CGImage, nil]; [countanimation setKeyPath:@"contents"]; [countanimation setValues:images]; [countanimation setCalculationMode:kCAAnimationDiscrete]; [countanimation setDuration:3.0f]; [countanimation setDelegate:self]; [countanimation setAutoreverses:NO]; [countanimation setRemovedOnCompletion:NO]; [countanimation setValue:@"Countdown" forKey:@"name"]; [countDown addAnimation:countanimation forKey:nil];
And want to hide the layer when the animation is stopped:
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { if([[anim valueForKey:@"name"] isEqual:@"Countdown"]) { [countDown setHidden:YES]; ... } }
The problem is that the layer blinks once with the original image (number 3) and hides after that.
I want to know why the layer goes back to the original, even if I set removedOnCompletion to NO .
source share