遇到的各种奇怪的问题

疑难杂症1:

在xcode中如果不通过 Assets.xcassets添加图片资源文件.

如果添加的是png图片格式, 直接用

[UIImage imageNamed:fileName]

 

否则用:

 NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:fileExt];
 image = [UIImage imageWithContentsOfFile:filePath];

用上述的方法是无法读取png格式图片的(正确的png格式)

如果图片是jpg格式的,你给改成png扩展名,xcode是无法读取的,读取的内容为nil

但是如果把png改成jpg的是可以的哈哈

 

对于png图片的时候, 还有2x和3x的问题.

有@2x的时候,1x图片都不敢用了现在是:(假设有两张图片: test.png和test@2x.png)

[UIImage imageNamed:@"test"] 等价于
[UIImage imageNamed:@"text@2x"]

 

 

 

posted on 2016-07-25 09:27  传说中的汽水枪  阅读(160)  评论(0编辑  收藏  举报

导航