3

I wanted to create a project without any storyboards.

I have deleted the Main and LaunchScreen storyboards.

As usual I added to my applicationDidFinishLaunchingWithOptions:

        window = UIWindow(frame: UIScreen.main.bounds
        window?.rootViewController = ViewController()
        window?.makeKeyAndVisible()

Now in Project Settings -> General if I leave Launch Screen File empty UIScreen.main.bounds is

(CGRect) $R12 = (origin = (x = 0, y = 0), size = (width = 320, height = 480))

And I get the following screen:

enter image description here

Now if I add something to the Launch Screen File field, in Info.plist -> Information Property List a new line with key Launch screen interface file base name appears and the bounds are correct. The bounds are correct even if the value is empty.

Why does the existence of Launch screen interface file base name affect UIScreen bounds?

Makaronodentro
  • 907
  • 1
  • 7
  • 21

1 Answers1

5

It started in iOS 8.0 when iPhone 6/6plus was released (TheFuquan user commented it started with the iPhone 5 release), in 2014. Back then if you wanted to support such new devices, you would definitely need, as it was required, to add a proper launch screen. Either through static image with different sizes for each devices you support OR through xib/storyboards.

Now, you answered your confusion already. The way to fix that is to provide a proper launch screen/image.

Apple's Human Interface Guidelines (Launch Screen): https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/launch-screen/

Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95
  • 2
    Actually it started with the first iPhone 5 going from the height of 480 to 568 – TheFuquan Jan 29 '19 at 21:32
  • What cracks me is that you don't even need to do provide a proper Launch Screen image. As long as the "Launch screen interface file base name" key exists in Info.plist UIScreen can calculate it's bounds – Makaronodentro Jan 30 '19 at 12:11
  • You either set sets of launch screen images OR provide that "launch screen interface file base name" to the Xcode project settings (or Info.plist, as you've mentioned). – Glenn Posadas Jan 30 '19 at 13:02