使用 Assets 配置 iOS Launch Image 尺寸大全
iOS App 打包上传时提示这样的错误:
ERROR ITMS-90096: "Your binary is not optimized for iPhone 5 -
New iPhone apps and app updates submitted must support the 4-inch display on iPhone 5 and must
include a launch image referenced in the Info.plist under
UILaunchImages with a
UILaunchImageSize value set to {320, 568}.
Launch images must be PNG files and located at the top-level of your bundle, or provided within each .lproj folder if you localize your launch images.
Learn more about iPhone 5 support and app launch images by reviewing the 'iOS Human Interface Guidelines' at https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen."
大概意思是 LaunchImage 尺寸不全,那到底需要哪些尺寸呢?
1 在 Assets 里新建一个 LaunchImage 资源
首先,在工程中某个 AssestsCatalog 里新建一个对象,并且把类型设置成 iOS LaunchImage:
2 配置图片
然后,勾选 App 需要兼容的设备,并放上对应尺寸的图片:
但是这里的命名让人十分疑惑,比如 2x、Retina 4 这些图片的像素值到底应该是多少呢?请参考下面的表格:
类别 | 机型/系统 | 宽 | 高 |
---|---|---|---|
iPhone XS Max iOS 12+ | iPhone XS Max | 1242 | 2688 |
iPhone XR iOS 12+ | iPhone XR | 828 | 1792 |
iPhone X iOS 11+ | iPhoneX | 1125 | 2436 |
iPhone Portrait iOS 8,9 | Retina HD 5.5 (iPhone 6 Plus) | 1242 | 2208 |
Retina HD 4.7 (iPhone 6) | 750 | 1334 | |
iPhone Portrait iOS 7-9 | 2x (iPhone 4) | 640 | 960 |
Retina 4 (iPhone 5) | 640 | 1136 | |
iPhone Portrait iOS 5,6 | 1x (iPhone 3) | 320 | 480 |
2x (iPhone 4) | 640 | 960 | |
Retina 4 (iPhone 5) | 640 | 1136 |
完整的尺寸列表可通过文末列出的参考链接查看。
3 设置项目的 LaunchImage
最后,在项目设置里选择刚刚配置的 LaunchImage 即可: