A truly versatile iOS launch screen using the Launch Screen.xib template?

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

According to this description, it can help create a launch screen that will work correctly on each device / resolution / orientation, and we no longer need to create a bunch of different screens for different resolutions using the asset catalog.

but ... I did not find a useful tutorial on how to actually use it to make one launch screen using one image for all resolutions (only for landscape).

I know how to create a user interface element focused on all resolutions using restrictions, but I cannot figure out how to scale the UIImage to fill the height of the screen for all resolutions. If I just resize my UIImage to fill the current screen size selected in Simulated Metrics - it will fill only that, but will not work with other screen sizes.

Can someone tell me? How to make UIImage fill the entire screen for all resolutions with this screen launcher pattern?

+5
source share
2 answers

If you just want to fill your launch screen with an image in each screen size, you can use the restrictions for the top, top, top and bottom levels between your UIImageView and the UIImageView . So:

Step 1 Add a UIImageView to your LaunchScreen.xib and set any image that it should display.

Step 2 Select the recently added UIImageView and click the "Pin" icon in the lower right corner of Interface Builder.

Step 3 Select all 4 og edges to set the constants to 0. This ensures that your UIImageView has 0 points of space for the supervisor on each edge.

It looks like this: enter image description here

However, 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 to show full-screen launch images. Instead, consider adding the elements that your startup image contains in the interface builder instead. Also remember that you (unfortunately) cannot link any code along with your launch .xib file.

+10
source

You need to add a UIImageView to view your xib file and set limits to fill the entire screen, for example. the distance on the left, right, top and bottom is 0. (You already mentioned that you can do this, so there are no more instructions for this)

Then you check your UIImageView , set the image you want to display, and select mode Aspect Fill as the view

enter image description here

Thus, your UIImageView takes an image and scales it, preserving its aspect ratio when filling all its contents.

+6
source

All Articles