How to get [UIImage imageWithContentsOfFile:] and High Res Images working

前端 未结 6 1190
星月不相逢
星月不相逢 2020-12-24 08:57

As many people are complaining it seems that in the Apple SDK for the Retina Display there\'s a bug and imageWithContentsOfFile actually does not automatically load the 2x i

6条回答
  •  悲哀的现实
    2020-12-24 09:52

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

    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:]
    

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

    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)

提交回复
热议问题