xcode 添加启动屏幕图像而不是使用 LaunchScreens.storyboard for iOS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51723797/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:43:40  来源:igfitidea点击:

Add Launch Screen Image instead of using LaunchScreens.storyboard for iOS

iosswiftxcodeprogrammaticallylaunch-screen

提问by Michael

I'm doing my UI for my iOS apps programmatically. The only things that is left is the LaunchScreen.storyboardwhere I didn't find a way around using it, yet. Strangely I can't find much about that in the internet.

我正在以编程方式为我的 iOS 应用程序制作 UI。唯一剩下的就是LaunchScreen.storyboard我还没有找到使用它的方法的地方。奇怪的是,我在互联网上找不到太多相关信息。

Is there a way to get rid of it and use an AssetSet instead?

有没有办法摆脱它并使用 AssetSet 代替?

LaunchScreen.storyboard

LaunchScreen.storyboard

That's (the highlighted file) what I want to get rid of

这就是(突出显示的文件)我想摆脱的

回答by DonMag

Since the question included "use a View or and UIImage instead?"

由于问题包括“改用 View 或 UIImage?”

From Apple's docs...

从苹果的文档...

Static Launch Screen Images

It's best to use an Xcode storyboard for your launch screen, but you can provide a set of static images if necessary.

静态启动屏幕图像

最好在启动屏幕上使用 Xcode 故事板,但如有必要,您可以提供一组静态图像。

Reference page, including a list of required image sizes: https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/launch-screen/

参考页面,包括所需图像尺寸的列表:https: //developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/launch-screen/

Note: To use images instead of a storyboard...

注意:要使用图像而不是故事板...

In Xcode open your Assets catalog (or create a new one), right-click in the assets section and select App Icons & Launch Images -> New iOS Launch Imageand it will create the proper template. Also go to project General settings and select Launch Images Source - Use Asset Catalog...

在 Xcode 中打开您的资产目录(或创建一个新的),右键单击资产部分并选择App Icons & Launch Images -> New iOS Launch Image,它将创建正确的模板。同时转到项目常规设置并选择Launch Images Source - Use Asset Catalog...

回答by Sh_Khan

There is noway to accomplish what you want , you have to supply a storyboard file for the launch screen in plist , if you want to customize go to the layout and add image or anything you want , there is no place to configure a programmatically UIViewfor that

有noway来完成你想要什么,你必须提供一个故事板文件在plist中推出屏幕,如果你想定制转到布局和添加图片或任何你想要的,也没有地方来配置编程UIView

回答by Michael

Here a short description of the steps based on the answer from https://stackoverflow.com/users/6257435/donmag:

以下是基于https://stackoverflow.com/users/6257435/donmag答案的步骤的简短描述:

  • create a new AssetSet: +-> AppIcons & Launch Images-> New iOS Launch Image
  • Go to your Target Settingsto General
  • Under App Icons and Launch Imagesclear the field Launch Screen File and select your LaunchScreen Asset set that you just created at Launch Images Source
  • You might have to delete the App from the device/simulator that you test it on and the new Launch Image should show up on start
  • 创建一个新的 AssetSet:+-> AppIcons & Launch Images-> New iOS Launch Image
  • 转到“目标设置”到“常规”
  • App Icons 和 Launch Images 下清除 Launch Screen File 字段并选择您刚刚在Launch Images Source 中创建的 LaunchScreen Asset 集
  • 您可能必须从测试它的设备/模拟器中删除该应用程序,新的启动图像应在启动时显示