IOS动画实现(2)ImageView自带动画

UIImageView官方文档(https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImageView_Class/index.html#//apple_ref/doc/uid/TP40006889)里面有说明

相关属性如下:

@property(nonatomiccopyNSArray *animationImages;  //需要动画动起来的几帧图片,这里存放一个循环所有的图片

@property(nonatomiccopyNSArray *highlightedAnimationImages; //动画动起来的几帧图片,当然,是为了高亮状态的

@property(nonatomicNSTimeInterval animationDuration; //一个循环所需要的时间,单位秒,默认值是[animaitonImages count]/30 秒

@property(nonatomicNSInteger animationRepeatCount; //循环的次数,默认0,无限循环

方法:

- (void)startAnimating

- (void)stopAnimating

- (BOOL)isAnimating

 

有了以上这些东西,就可以开始做一个动画了。最简单的就是加若干图片到animationImages,然后startAnimation即可。

如果需要细化速度等等元素,直接设置相关的属性即可。

网上查到有说这种实现动画的方式,内存未释放。实际上是把所有的帧,全部加载都内存中的。

亲测确实如此。这种方式,还是建议做那种小而美的动画即可,别用来做那种大图片的动画,否则内存吃不消哈。呵呵。 

posted on 2015-09-15 22:32  清风徐来,水波不兴  阅读(303)  评论(0编辑  收藏  举报

导航