找到你要的答案

Q:Truly universal iOS launch screen using Launch Screen.xib template?

Q:真正通用的iOS推出屏幕使用发射screen.xib模板?

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).

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..

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

所以,从Xcode 6我们已经有了一个新的超级有用的特征发射屏幕模板

根据它的描述,它可以帮助创建一个发射屏幕,将正确地工作在每一个设备/分辨率/方向,我们不必做一堆不同的屏幕,不同的决议与资产目录了。

但…我没有找到任何有用的教程,关于如何实际使用这个做一个单一的发射屏幕使用一个单一的图像的所有决议(只为景观)。

我知道如何使一个UI元素为中心对所有决议的约束,但我不知道如何让我的UIImage规模填补所有分辨率屏幕高度。如果我只是调整我的UIImage填补当前屏幕尺寸模拟指标选择它将只有那一个,但不会与其他屏幕尺寸的工作。

有人能告诉我一个线索吗?如何使UIImage所有决议使用这个启动屏幕模板填充整个屏幕?

answer1: 回答1:

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:

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

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

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: enter image description here

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.

如果你只是想填补你的启动屏幕在每一个屏幕大小的图像,你可以使用领先,尾随,顶部和底部的UIImageView和视图之间的约束你。所以:

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

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

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: enter image description here

说,你应该考虑如果这是去的路。有一个想法。XIB文件作为启动屏幕真的是为了取代有显示全屏发射图像的需要。相反,考虑放置任何元素,你的发射图像包含在界面建设者。还记得你(不幸的是)不能够把任何代码连同你的启动屏幕。xib文件。

answer2: 回答2:

You need to add an UIImageView to view to your xib file and set the constraints to fill the entire screen, e.g. spacing left, right, top and bottom equal to 0. (You already mentioned you can do this, therefore no more instructions regarding this)

Then you inspect your UIImageView, set your desired image you want to display and choose as view mode Aspect Fill

That way your UIImageView takes the image and scales it up, keeping it aspect ratio while filling its entire content.

你需要添加一个UIImageView来查看你的XIB文件和设置的限制,充满了整个屏幕,如距左、右、顶部和底部等于0。(你已经提到你可以做到这一点,因此没有更多关于此的指示)

然后你检查你的UIImageView,你想显示和选择视图模式方面填补设定您所需的图像

这样你将图像缩放UIImageView,保持纵横比的同时填充整个内容。

ios  xcode  user-interface  splash-screen