怎样链,一个iPhone的UIImageView规模动画? [英] How do I chain scale animations with an iPhone UIImageView?
问题描述
我想下来缩放图像,将图像,那么它的规模回来了。
I'm trying to scale an image down, change the image, then scale it back up.
CABasicAnimation* shrink = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shrink.toValue = [NSNumber numberWithDouble:0];
shrink.duration = 1;
shrink.delegate = self;
[myImageView.layer addAnimation:shrink forKey:@"shrink"];
使得收缩,那么它完成时,我改变形象,并开始成长:
makes the shrink, then when it completes, I change the image, and start the grow:
- (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"];
}
这在模拟器上的伟大工程,但在设备上,收缩完成时,我得到了全尺寸的,旧图像的闪烁,然后养成动画开始与新的形象。
This works great on the simulator, but on the device, when the shrink completes, I get a flash of the full-size, old image, then the grow animation begins with the new image.
不知道如何摆脱闪光灯?
Any idea how to get rid of that flash?
(我试过removedOnCompletion = NO;,并试图设置的AffineTransform等于第一个完成后按比例缩小的尺寸,但没有多少运气)
(I've tried "removedOnCompletion = NO;" and attempted setting the affineTransform equal to the scaled down size after the first completion, but didn't have much luck.)
任何提示AP preciated。
Any tips appreciated.
KB
编辑:
好极了!设置如下:
shrink.fillMode = kCAFillModeForwards;
shrink.removedOnCompletion = NO;
删除闪烁。谢谢,本!
Removed the flashing. Thanks, Ben!
推荐答案
尝试设置动画的在fillMode
到 kCAFillModeForwards
。这应该离开这个项目,因为它是在动画的结尾,而不是之前。
Try setting your animation's fillMode
to kCAFillModeForwards
. That should leave the item as it was at the end of the animation, rather than before.
这篇关于怎样链,一个iPhone的UIImageView规模动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!