使用Launch Screen.xib模板真正实现通用iOS启动屏幕? [英] Truly universal iOS launch screen using Launch Screen.xib template?

查看:195
本文介绍了使用Launch Screen.xib模板真正实现通用iOS启动屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,从Xcode 6开始,我们得到了一个新的超级实用的启动屏幕模板功能

So, starting with Xcode 6 we have got a new super-useful feature of Launch Screen template

根据它的描述,它可以帮助创建一个可以在每个设备/分辨率/方向上正常工作的启动屏幕,我们不必为不同的屏幕制作一堆不同的屏幕分辨率与资产目录不再。

According to it's description it can help create a launch screen that will work correctly on every device/resolution/orientation and we don't have to make a bunch of different screens for different resolutions with Assets Catalog anymore.

但是......我没有找到任何有用的教程,如何实际使用它来使用单个图像制作单个图像所有决议(仅适用于风景)。

but... I have failed to find any useful tutorial on how to actually use this to make a single launch screen using a single image for all resolutions (only for landscape).

我知道如何使用约束使UI元素以所有分辨率为中心,但我无法弄清楚如何使我的UIImage缩放在所有分辨率上填充屏幕高度。如果我只是调整我的UIImage以填充模拟指标中选择的当前屏幕尺寸 - 它将只填充那个,但不适用于其他屏幕尺寸..

I know how to make a UI element centered on all resolutions using constraints, but i can't figure out how to make my UIImage scale to fill screen height on all resolutions. If i just resize my UIImage to fill current screen size selected in Simulated Metrics - it will fill only that one, but will not work with other screen sizes..

可以有人给我个提示?如何使用此启动屏幕模板使UIImage为所有分辨率填充整个屏幕?

Can somebody give me a clue? how to make UIImage fill entire screen for all resolutions using this Launch Screen template?

推荐答案

如果你只是想用每个屏幕大小的图像填充你的启动画面,你可以使用前导,尾随,您的 UIImageView 和超级视图之间的顶部和底部约束。所以:

If you simply just want to fill your launch screen with an image in every screen size, you can use leading, trailing, top and bottom constraints between your UIImageView and the superview. So:

第1步
UIImageView 添加到 LaunchScreen.xib 并设置它应显示的任何图像。

Step 1 Add your UIImageView to your LaunchScreen.xib and set whatever image it should display.

第2步
选择新添加的 UIImageView ,然后单击Interface Builder右下角的Pin图标。

Step 2 Select your newly added UIImageView and click the "Pin" icon at the bottom right of Interface Builder.

步骤3
选择所有4个边缘og将常量设置为0.这样可以确保 UIImageView 在superview上有0个空间点每一个优势。

Step 3 Select all 4 edges og set the constants to 0. This makes sure that your UIImageView has 0 points of space to the superview on every edge.

它看起来像这样:

It looks like this:

那就是说,你应该考虑这是否可行。将.xib文件作为启动屏幕的想法实际上是为了取代必须显示全屏启动图像的需要。相反,请考虑将启动图像包含的任何元素放在界面构建器中。另请记住,您(遗憾的是)无法将任何代码与启动屏幕.xib文件绑定在一起。

That said, you should consider if this is the way to go. The idea of having a .xib file as a launch screen is really intended to replace the need of having to show full screen launch images. Instead, consider placing whatever elements your launch image contains in the interface builder instead. Also remember that you're (unfortunately) not able to tie any code together with your launch screen .xib file.

这篇关于使用Launch Screen.xib模板真正实现通用iOS启动屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆