我正在尝试缩小图像,更改图像,然后将其缩小.
CABasicAnimation* shrink = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; shrink.toValue = [NSNumber numberWithDouble:0]; shrink.duration = 1; shrink.delegate = self; [myImageView.layer addAnimation:shrink forKey:@"shrink"];
缩小,然后当它完成时,我改变图像,并开始增长:
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag { myImageView.image = [images objectAtIndex:image]; CABasicAnimation* grow = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; grow.toValue = CGAffineTransformMakeScale(1,1); grow.delegate = self; grow.duration = 1; [myImageView.layer addAnimation:grow forKey:@"grow"]; }
这在模拟器上运行得很好,但是在设备上,当收缩完成时,我得到一个全尺寸旧图像的闪光,然后成长动画以新图像开始.
知道如何摆脱闪光灯吗?
(我尝试过"removedOnCompletion = NO;"并尝试将affineTransform设置为在第一次完成后缩小尺寸,但没有太多运气.)
任何提示赞赏.
KB
编辑:
优秀!设置以下内容:
shrink.fillMode = kCAFillModeForwards; shrink.removedOnCompletion = NO;
删除了闪烁.谢谢,本!
尝试将动画设置fillMode
为kCAFillModeForwards
.这应该使项目保持在动画结束时,而不是之前.