ios 如何在 Xcode 中设置启动屏幕图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31025261/
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
How to set a launch screen image in Xcode
提问by Skywalker
I am working on a iPhone App and I am trying to set a launch screen image.
How can I set a launch screen image, is it possible to add a UIImageViewand assign it a image?
我正在开发 iPhone 应用程序,并且正在尝试设置启动屏幕图像。
如何设置启动屏幕图像,是否可以添加UIImageView并为其分配图像?
If you need more information to answer the question then please let me know.
如果您需要更多信息来回答问题,请告诉我。
Thanks in advance
提前致谢


回答by danialzahid94
Yes, you can easily set a UIImageViewin the LaunchScreen. Simply delete the pre-existing labels from the LaunchScreen.xib, add a UIImageViewfrom the Interface Builder. Assign the following 4 constraints to that UIImageViewwith respect to the parent view:
是的,您可以轻松地UIImageView在 LaunchScreen 中设置 a 。只需从 中删除预先存在的标签LaunchScreen.xib,UIImageView从界面生成器中添加一个。将以下 4 个约束分配给与UIImageView父视图相关的约束:
- Bottom Space to container
- Top Space to container
- Leading Space to Container
- Trailing Space to Container
- 容器底部空间
- 到容器的顶部空间
- 引领空间到集装箱
- 到容器的尾随空间
And finally set the image to the UIImageView.
最后将图像设置为UIImageView.
Hope this helps you in what you wanted to do.
希望这可以帮助您完成您想做的事情。
Update:
更新:
Have a look at the following image for further description:
看一下下面的图片以获得进一步的描述:


回答by Oleksandr
In iOS 8 and later, you can create a XIB or storyboard file instead of a static launch image. When you create a launch file in Interface Builder, you use size classes to define different layouts for different display environments and you use Auto Layout to make minor adjustments.
在 iOS 8 及更高版本中,您可以创建 XIB 或故事板文件而不是静态启动图像。当您在 Interface Builder 中创建启动文件时,您可以使用 size classes 为不同的显示环境定义不同的布局,并使用 Auto Layout 进行细微调整。
回答by mobileappDev
For adding a launchimage(or any type of image), in Xcode(9.4.1), simply go the Assets.xcassets and you can add it from the self-explanatory addition feature there. For my iphone app, i simply added it, in a jiffy. Also, you need to follow the instructions for adding constraints for the image, as described by one of the answerers with screenshot, above. Finally, you can save and test to see/verify your launch image appearing in the launch of your app.
要添加启动图像(或任何类型的图像),在 Xcode(9.4.1) 中,只需转到 Assets.xcassets,您就可以从那里的不言自明的添加功能中添加它。对于我的 iphone 应用程序,我只是在瞬间添加了它。此外,您需要按照上面带有屏幕截图的回答者之一所述为图像添加约束的说明进行操作。最后,您可以保存并测试以查看/验证您的应用启动时出现的启动图像。

