iOS8 两种image方法 对@2x @3x 加载选取的解析
2015-06-01 16:59
393 查看
取image方法1
UIImage *image = [UIImageimageNamed:@"图片名字"];//没有
@2x @3x
输出:
2015-06-01 16:30:33.219 test[4676:1829040] device: iPhone 4s *** imageData.length: 1107
2015-06-01 16:29:30.001 test[4617:1819270] device: iPhone 5 *** imageData.length: 1107
2015-06-01 16:27:57.803 test[4535:1810875] device: iPhone 5s *** imageData.length: 1107
2015-06-01 16:25:45.310 test[4476:1798634] device: iPhone 6 *** imageData.length: 1107
2015-06-01 16:33:11.060 test[4751:1848019] device: iPhone 6 Plus *** imageData.length: 1840
[b]取image方法2
[/b]
NSString *path = [[NSBundlemainBundle]pathForResource:@"图片名字"ofType:@"png"];//没有 @2x
@3x
UIImage *image = [[UIImagealloc]initWithContentsOfFile:path];
注:initWithContentsOfFile 方法需要@1x的图片 不然获取不到图片
输出:
2015-06-01 16:50:09.486 test[5168:1954713] device: iPhone 4s *** imageData.length: 1107
2015-06-01 16:49:44.608 test[5116:1951056] device: iPhone 5 *** imageData.length: 1107
2015-06-01 16:44:16.885 test[4974:1921579] device: iPhone 5s *** imageData.length: 1107
2015-06-01 16:45:40.441 test[5032:1932897] device: iPhone 6 *** imageData.length: 1107
2015-06-01 16:42:36.905 test[4920:1907182] device: iPhone 6 Plus *** imageData.length: 1840
通过测试 可以发现两种方法在iPhone 6 Plus 上都会优先加载
@3x 图片,在其他测试机型上加载 @2x 图片。
UIImage *image = [UIImageimageNamed:@"图片名字"];//没有
@2x @3x
输出:
2015-06-01 16:30:33.219 test[4676:1829040] device: iPhone 4s *** imageData.length: 1107
2015-06-01 16:29:30.001 test[4617:1819270] device: iPhone 5 *** imageData.length: 1107
2015-06-01 16:27:57.803 test[4535:1810875] device: iPhone 5s *** imageData.length: 1107
2015-06-01 16:25:45.310 test[4476:1798634] device: iPhone 6 *** imageData.length: 1107
2015-06-01 16:33:11.060 test[4751:1848019] device: iPhone 6 Plus *** imageData.length: 1840
[b]取image方法2
[/b]
NSString *path = [[NSBundlemainBundle]pathForResource:@"图片名字"ofType:@"png"];//没有 @2x
@3x
UIImage *image = [[UIImagealloc]initWithContentsOfFile:path];
注:initWithContentsOfFile 方法需要@1x的图片 不然获取不到图片
输出:
2015-06-01 16:50:09.486 test[5168:1954713] device: iPhone 4s *** imageData.length: 1107
2015-06-01 16:49:44.608 test[5116:1951056] device: iPhone 5 *** imageData.length: 1107
2015-06-01 16:44:16.885 test[4974:1921579] device: iPhone 5s *** imageData.length: 1107
2015-06-01 16:45:40.441 test[5032:1932897] device: iPhone 6 *** imageData.length: 1107
2015-06-01 16:42:36.905 test[4920:1907182] device: iPhone 6 Plus *** imageData.length: 1840
通过测试 可以发现两种方法在iPhone 6 Plus 上都会优先加载
@3x 图片,在其他测试机型上加载 @2x 图片。
相关文章推荐
- zoj1489 hdu 1395 (数论)
- smartfoxserver2X入门指导翻译2
- SmartFoxServer 2X 安装
- studio3.0 输入法
- APP切图详细规范终极指南
- iOS @2x 与@3x 图的详解
- 实现iOS图片等资源文件的热更新化(二):自定义的动态 imageNamed
- 移动端关于@2x与@3x的图片加载问题解决方法
- ios Undefined symbols for architecture arm64:错误解决
- 传智播客IOS 4期学习总结
- IOS:蓝牙技术
- ios 开发中获取字符串中重复的字符的rang
- Visual Studio 2013: Error: 无法打开源文件 "iostream"
- iOS facebook PoP 初体验
- 基于iOS 使用GCD实现列表界面的图片异步下载
- xml解析
- 最近遇到的一个关于iOS屏幕旋转的坑,而且还是自己无意中挖的
- iOS首页广告无限轮播
- 隐藏键盘的方法
- iOS开发摇动手势实现详解