博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于UIImageView帧动画内存无法释放的问题
阅读量:7008 次
发布时间:2019-06-28

本文共 1346 字,大约阅读时间需要 4 分钟。

UIImageView帧动画相关属性和方法:需要播放的序列帧图片数组(里面都是UIImage对象,会按顺序显示里面的图片)@property(nonatomic,copy) NSArray *animationImages;帧动画的持续时间@property(nonatomic) NSTimeInterval animationDuration;帧动画的执行次数(默认是无限循环)@property(nonatomic) NSInteger animationRepeatCount;开始执行帧动画- (void)startAnimating;停止执行帧动画- (void)stopAnimating;是否正在执行帧动画- (BOOL)isAnimating;例:加载动画图片的方式// 1.加载所有的动画图片- (void)runAnimationWithCount:(int)count name:(NSString *)name{if (self.imageView.isAnimating) return;// 1.加载所有的动画图片NSMutableArray *images = [NSMutableArray array];for (int i = 0; i// 计算文件名NSString *filename = [NSString stringWithFormat:@"%@_d.jpg", name, i];// 加载图片// imageNamed: 有内存缓存直到程序退出才释放(传入文件名)// UIImage *image = [UIImage imageNamed:filename];// imageWithContentsOfFile: 没有缓存,自动释放(传入文件的全路径)NSBundle *bundle = [NSBundle mainBundle];NSString *path = [bundle pathForResource:filename ofType:nil];UIImage *image = [UIImage imageWithContentsOfFile:path];// 添加图片到数组中[images addObject:image];}self.imageView.animationImages = images;// 2.设置播放次数(1次)self.imageView.animationRepeatCount = 1;// 3.设置播放时间self.imageView.animationDuration = images.count * 0.05;[self.imageViewstartAnimating];// 4.动画放完1秒后清除内存CGFloat delay = self.tom.animationDuration;[self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:delay]; }

 

转载于:https://www.cnblogs.com/xiehan87/p/5038669.html

你可能感兴趣的文章
glusterfs Self-Heal and Re-Balance Operations
查看>>
Python文件夹与文件的操作
查看>>
Apache 启动遇到问题解决
查看>>
final和static
查看>>
win7 64位 下USB转COM驱动安装方法
查看>>
QString 与中文问题
查看>>
MPLS ××× 配置步聚
查看>>
BGP 管理距离修改及分析
查看>>
我的友情链接
查看>>
uptime详解,最通俗的说明了cpu平均负载
查看>>
docker-compose 学习:通过 Dockerfile 和 build 指令搭建 LNMP
查看>>
关于android服务器推送解决方案的学习
查看>>
我的友情链接
查看>>
归档模式和非归档模式 Oracle 10g学习系列(4)
查看>>
多线程程序,只有黑盒测试是不够的!
查看>>
服务器上安装nodejs
查看>>
Python 自动化运维1-拷贝
查看>>
单独编译apache的rewrite模块--收藏
查看>>
一次利用nginx漏洞的***事件
查看>>
我的友情链接
查看>>