且构网

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

如何让 [UIImage imageWithContentsOfFile:] 和高分辨率图像工作

更新时间:2023-02-14 07:41:52

好的,Michael 在这里找到的实际解决方案:http://atastypixel.com/blog/uiimage-resolution-independence-and-the-iphone-4s-retina-display/

Ok, actual solution found by Michael here : http://atastypixel.com/blog/uiimage-resolution-independence-and-the-iphone-4s-retina-display/

他发现 UIImage 有一个方法initWithCGImage",它也接受一个比例因子作为输入(我猜你可以设置自己的比例因子的唯一方法)

He figured out that UIImage has the method "initWithCGImage" which also takes a scale factor as input (I guess the only method where you can set yourself the scale factor)

[UIImage initWithCGImage:scale:orientation:]

这似乎很好用,您可以自定义加载高分辨率图像并将比例因子设置为 2.0

And this seems to work great, you can custom load your high res images and just set that the scale factor is 2.0

imageWithContentsOfFile 的问题在于,由于它目前无法正常工作,因此即使它已修复,我们也无法信任它(因为某些用户的设备上仍会使用较旧的 iOS)

The problem with imageWithContentsOfFile is that since it currently does not work properly, we can't trust it even when it's fixed (because some users will still have an older iOS on their devices)