1

I've add different size images into LaunchImage asset. While I use this code

UIImage *launchImage = [UIImage imageNamed:@"LaunchImage"]

It has returned the launchImage with the wrong size, exactly returns @2x png. When i use iphone6 plus, the expecting image is @3x png. Any idea about getting the right image?

Qijin
  • 307
  • 2
  • 13

1 Answers1

5

After searching a lot, i found that the LaunchImages are special, and aren't actually an asset catalog on the device. And the launchImage file name for all iOS devices list as:

  • LaunchImage-568h@2x.png
  • LaunchImage-700-568h@2x.png
  • LaunchImage-700-Landscape@2x~ipad.png
  • LaunchImage-700-Landscape~ipad.png
  • LaunchImage-700-Portrait@2x~ipad.png
  • LaunchImage-700-Portrait~ipad.png
  • LaunchImage-700@2x.png
  • LaunchImage-Landscape@2x~ipad.png
  • LaunchImage-Landscape~ipad.png
  • LaunchImage-Portrait@2x~ipad.png
  • LaunchImage-Portrait~ipad.png
  • LaunchImage.png
  • LaunchImage@2x.png
  • LaunchImage-800-667h@2x.png (iPhone 6)
  • LaunchImage-800-Portrait-736h@3x.png (iPhone 6 Plus Portrait)
  • LaunchImage-800-Landscape-736h@3x.png (iPhone 6 Plus Landscape)

so if you want to get the right launch image for iphone device, just use this code:

    NSString *launchImageName;
    if([UIScreen mainScreen].bounds.size.height > 667.0f) {
        launchImageName = @"LaunchImage-800-736h"; // iphone6 plus
    }
    else if([UIScreen mainScreen].bounds.size.height > 568.0f) {
        launchImageName = @"LaunchImage-800-667h"; // iphone6
    }
    else if([UIScreen mainScreen].bounds.size.height > 480.0f){
        launchImageName = @"LaunchImage-700-568h";// iphone5/5plus
    } else {
        launchImageName = @"LaunchImage-700"; // iphone4 or below
    }
    UIImage *launchImage = [UIImage imageNamed:launchImageName];
Qijin
  • 307
  • 2
  • 13
  • 1
    It works, however, for the iPhone 6 Plus, you need to include the orientation as well. So it should be "LaunchImage-800-Portrait-736h" for portrait mode. Thanks! – Bassem Sameh Jan 05 '16 at 14:40
  • What are the "special" names for iphone-x and newer? anybody knows? – C. Kontos Dec 14 '18 at 12:42