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

会有一股神秘感。 提交于 2019-12-03 08:23:21

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:

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!