UIImageView startAnimating:如何让它停止在该系列的最后一张图片上?
我正在使用UIImageView创建一个简单的动画,一切都很完美,但是当我使用startAnimating时,动画会运行一次(我希望它),但是回到第一帧。我希望动画在最后一帧停止。
I am using UIImageView to create a simple animation and everything works perfectly, but when I use startAnimating, the animation will run once (as I want it to) but go back to the first frame. I want the animation to stop on the last frame.
我使用:
myAnimation.animationImages = myArray;
myAnimation.animationDuration = 0.7;
myAnimation.animationRepeatCount = 1;
[myAnimation startAnimating];
我是否可以使用覆盖startAnimating方法?解决问题的最佳方法是什么?
Could I have to use override the startAnimating method? What is the best way to fix my problem?
在开始设置动画之前,请在图像视图中设置最后一个图像 imageView.image = yourLastImage;
然后启动动画。动画完成后,图像视图将显示yourLastImage。
Before you start animating, set the last image in the image view imageView.image = yourLastImage;
and then start the animation. After the animation is complete the image view will show yourLastImage.
至于NSTimer的事情,除了默认动画结束之外别无其他选择。因此,如果您想在动画完成后执行任何操作,则必须依赖NSTimer作为deanWombourne建议。
As for the NSTimer thing, theres no other alternative to know when the default animation has ended. So if you want to do anything after the animation completes, you have to rely on NSTimer as deanWombourne suggested.