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