我正在这样设置动画:
self.testAnimation = [CAKeyframeAnimation animationWithKeyPath:@"TestAnimation"];
[self.animationImagesAsCGImages addObject:( id )[UIImage imageNamed:@"c1.png"].CGImage];
[self.animationImagesAsCGImages addObject:( id )[UIImage imageNamed:@"c2.png"].CGImage];
[self.animationImagesAsCGImages addObject:( id )[UIImage imageNamed:@"c3.png"].CGImage];
[self.animationImagesAsCGImages addObject:( id )[UIImage imageNamed:@"c4.png"].CGImage];
[self.animationKeyframeTimings addObject:[NSNumber numberWithFloat:0.0f]];
[self.animationKeyframeTimings addObject:[NSNumber numberWithFloat:0.25f]];
[self.animationKeyframeTimings addObject:[NSNumber numberWithFloat:0.5f]];
[self.animationKeyframeTimings addObject:[NSNumber numberWithFloat:0.75f]];
self.testAnimation.values = self.animationImagesAsCGImages;
self.testAnimation.keyTimes = self.animationKeyframeTimings;
self.testAnimation.repeatCount = HUGE_VALF;
self.testAnimation.autoreverses = NO;
self.testAnimation.calculationMode = kCAAnimationDiscrete;
self.testAnimation.duration = 2.0f;
然后这样称呼它:
[self.layer addAnimation:self.testAnimation forKey:@"TestAnimation"];
但什么都没有显示。
我看过其他几篇关于 kCAAnimationDiscrete 的 Stack 帖子需要第一个时间为 0.0f,如您所见。
请指教?