1

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

但是,在仍然调用AND之后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];
}
}

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

谢谢!

4

0 回答 0