Search code examples
swift3ios8storyboardinterface-builderios11

Creating Launch Screen.xib for iOS8 ( ... iOS11, Swift 4 and LaunchScreen.storyboard )


I've just found out that in order to be able to have the description for your app in the app store say "This app is optimized for iPhone 6, and iPhone 6 Plus." you need to use a launch XIB or storyboard file for your launch images (per [Apple][1]).

So, I've created a new Launch Screen xib and now I'm a little but since I usually do everything in code and don't use interface builder. I've deleted the default label that is inserted and dropped a UIImageView into the view. Now I'm wondering how would I:

1) Tell the UIImageView to resize to the size of whatever screen it's on

2) Tell the UIImageView to pick ImageA if a 3.5 inch screen is running the app or the ImageB if a 4 inch screen is running the app etc. etc.

Essentially, I'm just trying to get the launch .xib to mimic the behavior of how the launch screen works normally. Would appreciate it if anyone could provide some assistance on this!


Solution

  • You have two options:

    1. You make use of autolayout and give the imageview a fullscreen appearance (distance to top, bottom, left and right equals 0). This would however result in a clipping of the image for certain screen sizes, what you may not want. So you might want to consider (2)

    2. You place the launch screen image into an asset catalog and just put different images into the different size classes.