Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 420
mr.dog Avatar asked May 02 '15 10:05

mr.dog


2 Answers

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.

like image 184
Steffen D. Sommer Avatar answered Jan 04 '23 05:01

Steffen D. Sommer


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

enter image description here

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

like image 39
luk2302 Avatar answered Jan 04 '23 06:01

luk2302