xcode iOS:为所有设备启动 Image,包括 iPad Pro
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39900225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS: Launch Image for all devices, include iPad Pro
提问by user6539552
I followed the guidelines on making the static launch screen images.
我遵循了制作静态启动屏幕图像的指南。
Yet, then I added the images to the xcassets as LaunchImage
然而,然后我将图像添加到 xcassets 作为 LaunchImage
However, they did not fill in the asset as expected. There are warnings warn about I need to have screen sizes such as 2208x1242, etc. Where I can have all the sizes needed for an App?
但是,他们没有按预期填写资产。有警告警告我需要屏幕尺寸,例如 2208x1242 等。我在哪里可以拥有应用程序所需的所有尺寸?
Also, why there is no iPad Pro launch images? How can I add it? Thanks.
另外,为什么没有 iPad Pro 启动图像?我怎样才能添加它?谢谢。
回答by Rob
If you drag an image into the launch image asset catalog, it will warn you that it's not the right dimensions, and will tell you what the dimensions should be. From that you can conclude:
如果您将图像拖到启动图像资产目录中,它会警告您它的尺寸不正确,并会告诉您尺寸应该是多少。从中你可以得出结论:
iPhone Portrait iOS 5,6@1x: 320x480 iPhone Portrait iOS 5,6@2x: 640x960 iPhone Portrait iOS 5,6@Retina 4: 640x1136 iPad Portrait Without Status Bar iOS 5,6@1x: 768x1004 iPad Portrait Without Status Bar iOS 5,6@2x: 1536x2008 iPad Portrait iOS 5,6@1x: 768x1024 iPad Portrait iOS 5,6@2x: 1536x2048 iPad Landscape Without Status Bar iOS 5,6@1x: 1024x748 iPad Landscape Without Status Bar iOS 5,6@2x: 2048x1496 iPad Landscape iOS 5,6@1x: 1024x768 iPad Landscape iOS 5,6@2x: 2048x1536 iPhone Portrait iOS 8,9@Retina HD 5.5: 1242x2208 iPhone Portrait iOS 8,9@Retina HD 4.7: 750x1334 iPhone Landscape iOS 8,9@Retina HD 5.5: 2208x1242 12.9-inch iPad Pro Portrait: 2048x2732 12.9-inch iPad Pro Landscape: 2732x2048 iPhone Portrait iOS 7-9@2x: 640x960 iPhone Portrait iOS 7-9@Retina 4: 640x1136 iPad Portrait iOS 7-9@1x: 768x1024 iPad Portrait iOS 7-9@2x: 1536x2048 iPad Landscape iOS 7-9@1x: 1024x768 iPad Landscape iOS 7-9@2x: 2048x1536 iPhone X Portrait iOS 11+: 1125×2436 iPhone X Landscape iOS 11+: 2436x1125
Note, it wouldn't give me the dimensions for the 12" iPad, so I got that from the iOS Human Interface Guidelines - Launch Screenwhich you included in your question.
请注意,它不会给我 12 英寸 iPad 的尺寸,所以我从iOS 人机界面指南 - 启动屏幕中得到了它,该指南包含在您的问题中。
回答by Quistard
To anyone reading this and is giving up hope on adding old style Launch Images for iPad Pro 10.5 inch, 11 inch and 12.9 inch, you can add them withoutusing the Storyboard or Launch Screen thing in XCode.
对于阅读本文并放弃为iPad Pro 10.5 英寸、11 英寸和 12.9 英寸添加旧式启动图像的任何人,您可以在不使用 XCode 中的 Storyboard 或 Launch Screen 内容的情况下添加它们。
The way we did it was by editing the .plist of our app:
我们这样做的方法是编辑我们的应用程序的 .plist:
<key>UILaunchImages</key>
<array>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>Default-Portrait</string> //iPad Pro 10.5"
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{768, 1024}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>12.0</string>
<key>UILaunchImageName</key>
<string>Default-Portrait-1194h</string> //iPad Pro 11"
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{834, 1194}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>9.0</string>
<key>UILaunchImageName</key>
<string>Default-Portrait-iPadPro</string>//iPad Pro 12"
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{1024, 1366}</string>
</dict>
</array>
(Be sure to remove the //iPad Pro comments obviously!)
(一定要明显删除 //iPad Pro 注释!)
And here are the filenames:
这是文件名:
iPad Pro 10.5":Default-Portrait@2x~ipad
iPad Pro 10.5":Default-Portrait@2x~ipad
iPad Pro 11":[email protected]
iPad Pro 11":[email protected]
iPad Pro 12":Default-Portrait-iPadPro@2x~ipad
iPad Pro 12":Default-Portrait-iPadPro@2x~ipad
Tested on all 3 of those devices and it works.
在所有 3 种设备上进行了测试,并且可以正常工作。
Hope this helps someone!
希望这对某人有帮助!
回答by Rob
回答by ErrorCode3000
Launch Screens should probably be taken care of by Storyboards rather than static images. However the Launch Screens aren't included in your Main.storyboard file. That way, Xcode will resize everything as expected with Auto Layout and you don't have to fill your app with tons of image files. So it'll work with the iPad Pro sizes 9.7" 2048 x 1536pxand 12.9", 2732 x 2048px.
Launch Screens 可能应该由 Storyboards 而不是静态图像来处理。但是,启动屏幕不包含在 Main.storyboard 文件中。这样,Xcode 将使用自动布局按预期调整所有内容的大小,您不必用大量图像文件填充您的应用程序。因此它适用于尺寸为 9.7" 2048 x 1536px和 12.9", 2732 x 2048px的 iPad Pro 。
In Xcode, go to File> New File> Launch Screen(Under the User Interface header) > then all the usual location and target adding bits.
在 Xcode 中,转到 文件>新建文件>启动屏幕(在用户界面标题下)> 然后是所有常用位置和目标添加位。
Creating a new Launch Image file
Edit it like you would in Interface Builder. As far as I'm aware, you can't assign a Class to it so don't expect any animations.
像在 Interface Builder 中一样编辑它。据我所知,你不能为它分配一个类,所以不要指望任何动画。