且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

imageWithContentsOfFile vs imageNamed(imageWithContentsOfFile返回低质量图像)

更新时间:2021-08-04 23:09:56

UIImage参考文档你可以看到imageNamed和imageWithContentsOfFile之间的一些区别。

In the UIImage reference documentation you can see a couple of differences between imageNamed and imageWithContentsOfFile.


  • imageWithContentsOfFile不会缓存图像,也不会查找视网膜显示版本(@ 2x.png)。

  • imageNamed而不是缓存图像并检查是否有@ 2x版本,以便在启用视网膜的设备中加载该图像。

知道了这一点,我能为您的问题考虑的最合理的解释是您正在使用视网膜设备并且具有相同图像的视网膜版本(@ 2x)。这可以解释为什么图像

Knowing this, the most logical explanation that I can think of for your problem is that you are using a retina device and have a retina version of that same image (@2x). That would explain why the image