我正在尝试缩小图像,更改图像,然后将其缩放。
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;
删除了闪烁。谢谢,本!