博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Fetching Image From Animating UIImageView的一点疑惑

Posted on 2013-02-01 18:01  酸梅拯救地球  阅读(201)  评论(0)    收藏  举报
myAnimation.animationImages = myArray;
myAnimation.animationDuration = 0.7;
myAnimation.animationRepeatCount = 1;
[myAnimation startAnimating];

      这里,myAnimation类型是UIImageView.

        由于功能需要,想取当前Animation的image.通过网上各种资料,目测不能实现.http://stackoverflow.com/questions/3351857/uiimageview-startanimating-how-do-you-get-it-to-stop-on-the-last-image-in-the-s?rq=1 给了很好的启示.(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).也就是说,因为NSTime的原因,没办法知道什么时候动画结束.(具体得研究ios sdk core Animation是实现机制).

       然后解决方法,stackoverflow的帖子也给了很好的解决方法.

      1.假画.在设置动画属性的时候 指定myAnimation 的 Image (也可以通过定时器之类的设定).

      2.Schedule an NSTimer to go off in 'animationDuration' seconds time.注意animationDuration的定义.The time duration is measured in seconds. The default value of this property is equal to the number of images multiplied by 1/30th of a second. Thus, if you had 30 images, the value would be 1 second.持续时间的测量单位是秒。此属性的默认值等于图像的数量乘以三十分之一。因此,如果你有30个图像,其值将是1秒。