1

I want my app to have different launch image when launched in portrait vs portrait upside down vs landscape left vs landscape right. Is that possible?

I'm willing to use any of the following:

  • Launch storyboard
  • Launch images in an asset catalog
  • Launch images as plain PNG files

To see why this is necessary, quit Camera.app and then launch it in landscape left and orientations. Notice the launch image, specifically that the shutter button is located near the home button in both landscape left and right orientations.

This is possible only if it has separate launch images / storyboards for landscape left and right. If it had only one, the shutter button would appear next to the home button in one orientation and next to the speaker (at the top of the screen) in the other orientation.

Camera.app seems to have four different launch images. How do I have four, as well?


EDIT: Based on the accepted answer, I tried adding the following launch images (without adding anything in Info.plist):

enter image description here

On my iPhone 7 Plus, it works correctly in portrait, landscape left and landscape right. Not when the phone is upside down, in which case the portrait launch image is shown, followed by what looks like a 180-degree rotation when the real UI is shown. To confirm this, I drew a big red rectangle in the middle of the portrait upside down launch image, and I don't see this red rectangle when I run the app, so I can confirm that the portrait upside down launch image file isn't being used at all. Do you know why? Do you see anything else wrong with the filenames?


EDIT 2: I added the following to Info.plist:

<key>UILaunchImages</key>
<array>
  <!-- 5.5-inch: -->
  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{414, 736}</string>
    <key>UILaunchImageOrientation</key>
    <string>Portrait</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{414, 736}</string>
    <key>UILaunchImageOrientation</key>
    <string>PortraitUpsideDown</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{414, 736}</string>
    <key>UILaunchImageOrientation</key>
    <string>LandscapeLeft</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{414, 736}</string>
    <key>UILaunchImageOrientation</key>
    <string>LandscapeRight</string>
  </dict>

  <!-- 4.7-inch: -->
  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{375, 667}</string>
    <key>UILaunchImageOrientation</key>
    <string>Portrait</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{375, 667}</string>
    <key>UILaunchImageOrientation</key>
    <string>PortraitUpsideDown</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{375, 667}</string>
    <key>UILaunchImageOrientation</key>
    <string>LandscapeLeft</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{375, 667}</string>
    <key>UILaunchImageOrientation</key>
    <string>LandscapeRight</string>
  </dict>

  <!-- 4-inch: -->
  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{320, 568}</string>
    <key>UILaunchImageOrientation</key>
    <string>Portrait</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{320, 568}</string>
    <key>UILaunchImageOrientation</key>
    <string>PortraitUpsideDown</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{320, 568}</string>
    <key>UILaunchImageOrientation</key>
    <string>LandscapeLeft</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
    <key>UILaunchImageSize</key>
    <string>{320, 568}</string>
    <key>UILaunchImageOrientation</key>
    <string>LandscapeRight</string>
  </dict>

  <!-- 3.5-inch: -->
  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
  </dict>

  <dict>
    <key>UILaunchImageName</key>
    <string>Default</string>
    <key>UILaunchImageMinimumOSVersion</key>
    <string>7.0</string>
  </dict>

</array>

This made things worse — I see a stretched out portrait launch image being used when the phone is in landscape.

Note that all the UILaunchImageName keys are set to Default, relying on iOS to disambiguate them. I also tried renaming the PNGs to things like Default-portrait-upside-down@3x.png and setting the UILaunchImageName to Default-portrait-upside-down. It made no difference.

Kartick Vaddadi
  • 4,818
  • 6
  • 39
  • 55
  • Do you have the upside down orientation enabled for iPhone? It is disabled by default in Info.plist for iPhones. – rob mayoff Apr 12 '17 at 14:11
  • I have it enabled. As I said the actual UI does show in portrait upside down orientation. Only the launch image doesn't. – Kartick Vaddadi Apr 12 '17 at 14:16
  • I don't have any other advice for you except to try using the UILaunchImages key instead. – rob mayoff Apr 12 '17 at 14:19
  • Thanks again, rob, I tried that, but it didn't work. Anything obviously wrong you see in the plist? – Kartick Vaddadi Apr 12 '17 at 15:20
  • If you want to use `UILaunchImages`, you need to give each file a different filename (`UILaunchImageName`). You can use the standard suffixes to give them different names. If you're using `UILaunchImages`, iOS won't add the suffixes for you. You need to include the suffixes explicitly. – rob mayoff Apr 12 '17 at 15:36
  • I tried three options, and none worked: First, I tried Default-LandscapeRight and the file was named Default-LandscapeRight@3x.png. Second, I tried putting @3x in the UILaunchImageName. Third, I tried renaming the file to Default-landscape-right@3x.png and changing the UILaunchImageName to Default-landscape-right. None of the three worked. – Kartick Vaddadi Apr 13 '17 at 07:57

1 Answers1

2

I believe you can specify a separate launch image for each orientation. iOS (since version 7.0) supports an Info.plist key UILaunchImages. The value is an array of dictionaries. Each dictionary describes one launch image. The dictionary can contain a key UILaunchImageOrientation, for which the value can be any of the four orientations.

Consult the Information Property List Key Reference for more details.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • Is this possible with an asset catalog? I use one currently, and can't find a way to do this. – Kartick Vaddadi Apr 12 '17 at 02:27
  • I don't see any documentation or Info.plist settings for using an asset catalog, but you're not required to put all your images in the catalog just because you have one. – rob mayoff Apr 12 '17 at 02:30
  • Thanks. In my case, it's simpler to eliminate the asset catalog and just have raw images. Do you know a reference to all the suffixes images can have like @2x, and which of these suffixes are required in the file name, and required in the plist entry? Many Stack Overflow questions have broken links to Apple documentation that's been removed when asset catalogs and launch storyboards were introduced. – Kartick Vaddadi Apr 12 '17 at 04:08
  • The `UILaunchImages` documentation says not to use suffixes for its images. For other images, as far as I know, [the only suffixes allowed are for screen scaling (`@2x`, `@3x`) and device type (`~iphone`, `~ipad`](https://developer.apple.com/library/content/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/SupportingHiResScreensInViews/SupportingHiResScreensInViews.html#//apple_ref/doc/uid/TP40010156-CH15-SW8) and I don't know of a complete reference. – rob mayoff Apr 12 '17 at 04:40
  • If you want to know the suffixes for use with `UILaunchImageFile`, they are in the [`UILaunchImageFile` documentation](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW24), but you don't need the suffixes if you use `UILaunchImages`. – rob mayoff Apr 12 '17 at 04:43