xcode 7 中没有 Retina 4 选项,那么如何在资产中设置全屏图像以使其在 4s/5s 和 iPhone 6 中正确显示?

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?

在xcode7中这些是没有retina 4选项的,根据,apple是故意去掉的。我确实编辑了 Contents.json 以取回它,但效果不一样!我记得在 XCode6/pre-iOS9 iPhone 6 中将使用视网膜 4 图片,所以我只需要为 iPhone 4/4 秒设置一张全屏 2x 图片,为 iPhone 5 设置一张全屏 Retina 4 /5s 和 6。

我认为 iPhone6 使用 Retina4 确实有意义,而 2x 则没有!因为1334/750约为1.778,接近于1136/640 = 1.775而960/640 = 1.5。我的 640*1136 图片在 iPhone6 上显示正常,而 640*960 图片失真。

但是有了Xcode7,即使我得到了retina 4选项,iPhone6仍然使用2x(640*960)图片而不是retina4图片(iPhone 5/5s确实使用 retina4 并且现在可以正确显示)。我尝试将设备类型从 iPhone 更改为通用,相同。

所以我的问题是 如果 apple 故意删除了 retina4 那么我如何在 xasset 中设置全屏图像以使其适用于 iPhone 4/5/6?我只是在谈论全屏图像。我了解使用 2x 的非全屏图像是有意义的。

顺便说一句,我不是在谈论 AppIcon 和 LaunchImage(视网膜 4 仍然存在并且可以工作)。我也不想编写额外的代码来使其工作(实际上这就是我目前所做的,就像这样 Fullscreen images on iPhone 6 with Asset Catalogs)。那么有没有可能我只是设置资产使其工作?

我向苹果技术支持提交了工单,他们确认目前没有办法做到这一点。我必须为它写一些代码。 "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. "

您可以修改定义图像集的JSON

  1. 在 Finder 中,转到图像集的文件夹。您可以右击 Xcode 内的图像集并选择 "Show in Finder".
  2. 打开Content.json文件
  3. 在 "images" 数组的 Json 上添加 "Retina 4 2x" 的定义。

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

例如,准备一个完整的空文件 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"
  }
}