No Retina 4 option in xcode 7 then how do I set fullscreen images in asset to make them show correctly in 4s/5s & iPhone 6?

放肆的年华 提交于 2019-12-24 12:26:07

问题


In xcode 7 these is no retina 4 option, according to this, apple removed it on purpose. I did edit Contents.json to get it back but the effect is not the same! I remember in XCode6/pre-iOS9 iPhone 6 will used retina 4 picture so I only need to set one fullscreen 2x picture for iPhone 4/4s, one fullscreen Retina 4 for iPhone 5/5s and 6.

I think using Retina4 for iPhone 6 really makes sense while 2x doesn't! Because 1334/750 is about 1.778, which is close to 1136/640 = 1.775 while 960/640 = 1.5. My 640*1136 pictures do show properly on iPhone 6 while 640*960 pictures are distorted.

But with Xcode 7 even I got the retina 4 option back, iPhone 6 still use 2x (640*960) picture instead of retina4 picture(iPhone 5/5s does use retina4 and shows properly now). I tried to change device type from iPhone to Universal, same.

So my question is if apple removed retina4 on purpose then how do I set fullscreen images in xasset to make them work for iPhone 4/5/6 ? I am only talking about fullscreen images. I understand for non-fullscreen images using 2x makes sense.

BTW I am not talking about AppIcon & LaunchImage (retina 4 is still there and works). I don't want to write extra code to make it work (actually this is what I currently do, like this Fullscreen images on iPhone 6 with Asset Catalogs) either. So is it possible that I just set asset to make it work ?


回答1:


I raised a ticket to apple technical support and they confirmed that currently there is no way to do that. I have to write some code for it. "Currently, there is no way for the Asset Catalog to load device specific images. If your app needs to support device specific images you will need to implement your own code to detect the screen size and choose the appropriate image. You can file an enhancement request by using the following link. Be sure to explain your use case for this feature. "




回答2:


You can modify the JSON that defines an Image Set

  1. In Finder, go to the folder of an image set. You can right-click image set inside Xcode and choose "Show in Finder".
  2. Open Content.json file
  3. Add definition of "Retina 4 2x" on Json in "images" array.

    { "idiom" : "iphone", "subtype" : "retina4", "scale" : "2x" },

For example, a complete empty file ready for iPhone:

{
  "images" : [
    {
      "idiom" : "iphone",
      "scale" : "1x"
    },
    {
      "idiom" : "iphone",
      "scale" : "2x"
    },
    {
      "idiom" : "iphone",
      "subtype" : "retina4",
      "scale" : "2x"
    },
    {
      "idiom" : "iphone",
      "scale" : "3x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}


来源:https://stackoverflow.com/questions/33406736/no-retina-4-option-in-xcode-7-then-how-do-i-set-fullscreen-images-in-asset-to-ma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!