Last active
June 4, 2018 02:47
-
-
Save zhangkn/8b5b8342808f6a7ca620a5123c5d187c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//方式一:有缓存(图片所占用的内存会一直停留在程序中) | |
+ (UIImage *)imageNamed:(NSString *)name;//name是图片的文件名 | |
//方式二:无缓存(图片所占用的内存会在一些特定操作后被清除) | |
+ (UIImage *)imageWithContentsOfFile:(NSString *)path | |
- (id)initWithContentsOfFile:(NSString *)path;//path是图片的全路径 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1、imageNamed 方式加载图片,内存由系统负责, | |
//即使帧图片对象数组失去animationImage数组的强引用,仍然会保存在内存 | |
//2. 无缓存加载方式 | |
[arrayImage addObject:[ UIImage imageWithContentsOfFile:path]]; | |
//当帧图片对象数组没有任何强参照引用时,立即被释放,占用内存少些 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment