简体   繁体   English

如何在 Xcode 资产目录中分配启动图像?

[英]How to assign launch images in Xcode assets catalog?

Xcode's interface for assigning launch images into an assets catalog is rather confusing. Xcode 用于将启动图像分配到资产目录的界面相当混乱。 Only 2 image slots are made available given the settings we've chosen (Portrait only, for iOS 8.0 and later) and yet the Apple docs list a variety of resolutions required for their various devices (6s, 6s Plus, 7, 7 Plus, etc.), 12 of them to be exact.根据我们选择的设置(仅限纵向,适用于 iOS 8.0 及更高版本),只有 2 个图像插槽可用,但Apple 文档列出了其各种设备(6s、6s Plus、7、7 Plus、等),确切地说是其中的 12 个。 I'm using Xcode 8.3 btw.顺便说一句,我正在使用 Xcode 8.3。

We are designing portrait images for commonly available devices, but how to assign them here?我们正在为常用设备设计人像图像,但如何在此处分配它们? Notice pics below showing a confusing mismatch between the expected resolutions of images (straight from Apple docs) and the Xcode UI for assigning those images.请注意下面的图片显示了图像的预期分辨率(直接来自 Apple 文档)和用于分配这些图像的 Xcode UI 之间令人困惑的不匹配。 There are only 6 slots available, and even if the Apple docs described only 6 images, it is impossible to tell which goes where.可用的插槽只有 6 个,即使 Apple 文档只描述了 6 个图像,也无法分辨哪个放在哪里。

EDIT : Deployment target is 8.3.编辑:部署目标是 8.3。

在此处输入图片说明 在此处输入图片说明

Depending on your deployment target, there's either 3 or 4 total resolutions you need to care about: 5.5" devices, 4.7" devices, 4" devices (eg iPhone SE), and if your deployment target is iOS 9 or below then 3.5" devices (eg iPhone 4S).根据您的部署目标,您需要关注 3 或 4 种总分辨率:5.5" 设备、4.7" 设备、4" 设备(例如 iPhone SE),如果您的部署目标是 iOS 9 或更低版本,则 3.5" 设备(例如 iPhone 4S)。

The "iOS 8.0 and Later" iPhone Portrait gives you the 5.5" and 4.7" devices. “iOS 8.0 及更高版本”iPhone Portrait 为您提供 5.5" 和 4.7" 设备。 If you check the "iOS 7.0 and Later" iPhone Portrait option that will give you "2x" (which I believe is 3.5" devices) and "Retina 4" (which is 4" devices).如果您选中“iOS 7.0 及更高版本”iPhone Portrait 选项,该选项将为您提供“2x”(我认为是 3.5 英寸设备)和“Retina 4”(即 4 英寸设备)。

Using those 4 options you'll be able to cover all supported iPhones.使用这 4 个选项,您将能够涵盖所有受支持的 iPhone。

If you need iPad support, you can check the relevant iPad checkbox.如果您需要 iPad 支持,您可以选中相关的 iPad 复选框。 However, it looks like the asset catalog doesn't offer a slot for either iPad Pro, I don't know why not.但是,资产目录似乎没有为 iPad Pro 提供插槽,我不知道为什么。 This answer suggests that for the iPad Pro you should ditch the asset catalog entirely and switch to free images and Info.plist keys. 这个答案表明,对于 iPad Pro,您应该完全放弃资产目录并切换到免费图像和 Info.plist 键。


You also don't need 12 images for 12 devices.您也不需要 12 个设备的 12 个图像。 A bunch of the devices share the same resolution.一堆设备共享相同的分辨率。 Here are the images you need:以下是您需要的图片:

  • 2048x2732 - 12.9" iPad Pro 2048x2732 - 12.9" iPad Pro
  • 1668x2224 - 10.5" iPad Pro 1668x2224 - 10.5" iPad Pro
  • 1536x2048 - 9.7" iPad, 7.9" iPad mini 4 1536x2048 - 9.7" iPad, 7.9" iPad mini 4
  • 1242x2208 - iPhone 6s Plus, iPhone 7 Plus, iPhone 8 Plus 1242x2208 - iPhone 6s Plus、iPhone 7 Plus、iPhone 8 Plus
  • 750x1334 - iPhone 6, iPhone 6s, iPhone 7, iPhone 8 750x1334 - iPhone 6、iPhone 6s、iPhone 7、iPhone 8
  • 640x1136 - iPhone 5, iPhone 5s, iPhone 5c, iPhone SE 640x1136 - iPhone 5、iPhone 5s、iPhone 5c、iPhone SE
  • 640x960 - iPhone 4s 640x960 - iPhone 4s

If you upgrade to Xcode 9 you'll also need an 1125x2436 image for the iPhone X.如果你升级到 Xcode 9,你还需要一个1125x2436的 iPhone X 图像。

If you would just use a launch storyboard like everyone else, you wouldn't be having any problem.如果你像其他人一样只使用启动故事板,你就不会有任何问题。 You would just supply one launch storyboard: end of story.您只需提供一个发布故事板:故事结束。

EDIT As of iOS 13 and Xcode 11, this will soon be required .编辑从 iOS 13 和 Xcode 11 开始,这将很快成为必需 Launch images are dead.启动图像已死。 Your app must have a launch storyboard.你的应用必须有一个启动故事板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM