CALayer
我使用以下代码为 a 的内容设置动画:
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];
...
}
}
问题是该层与原始图像(编号3)一起闪烁一次,然后隐藏。
我想知道为什么即使我设置removedOnCompletion
为NO
.