为什么在调用removeAllAnimations后调用animationDidStart?

时间:2013-05-21 17:41:56

标签: iphone ios core-animation catextlayer

animationDidStartCABasicAnimation委托)中,我想更新CATextLayer。但是,如果用户触摸屏幕,我想删除[self.maskLayer removeAllAnimations];所有正在进行的动画(所有动画都按顺序播放)。

然而,在removeAllAnimations之后,仍然会调用animationDidStartanimationDidStop,但动画本身并未显示。这显然不是我想要的。

动画添加如下:

- (void)addAnimations {

for (int i=1; i<6; i++) {
NSString* intValue = [NSString stringWithFormat:@"%d", i];

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];

animation.duration = 0.5;

animation.delegate = self;

animation.repeatCount = 0;

animation.autoreverses = NO;

[animation setValue:intValue forKey:@"animationString"];

animation.timingFunction = nil;

[animation setRemovedOnCompletion:NO];

[animation setFillMode:kCAFillModeForwards];

animation.fromValue = (id) [self getCGRectForZoomLevel:i];

animation.toValue = (id) [self getCGRectForZoomLevel:i + 1 ];

animation.beginTime = CACurrentMediaTime() + i * 2;

[self.shapeLayer addAnimation:animation forKey:intValue];
}
}

如何防止这种情况?这个问题花了我几个小时的时间:(

谢谢!

0 个答案:

没有答案