iOS8 两种image方法 对@2x @3x 加载选取的解析

取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


取image方法2

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 图片。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值