我使用以下代码来实现对
当动画停止时,想要隐藏该层:
问题在于该图层在原始图像(number3)闪烁一次后就被隐藏了。即使我将“removedOnCompletion”设置为“NO”,我仍然想知道为什么该图层会返回到原始状态。
CALayer
内容的动画效果: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];
当动画停止时,想要隐藏该层:
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
if([[anim valueForKey:@"name"] isEqual:@"Countdown"])
{
[countDown setHidden:YES];
...
}
}
问题在于该图层在原始图像(number3)闪烁一次后就被隐藏了。即使我将“removedOnCompletion”设置为“NO”,我仍然想知道为什么该图层会返回到原始状态。