Aspect Ratio of Background Image for iPhone X

1k views Asked by At

I have an app which has image asset with 3 size images @1, @2, @3 as a background image.

I implement launch screen into my project to make app seen as fullscreen on iPhone X. As you know, launch screen asset has size for iPhone X so launch screen looks okay. However, my background image doesn't look good because @3s' aspect ratio is for plus devices not iPhone X.

Where should I add a proper size image?

EDIT: My question is not about launch screen Image. It is about an background image that I use on regular ViewController

2

There are 2 answers

1
Ashley Mills On BEST ANSWER

Rather than use an image as your launch screen, you should try using a launch storyboard.

This could contain a single view controller that contains a UIImageView, with contentMode = .aspectFill. This will clip some of the image on either side, but this might be acceptable to you.

0
Mr Some Dev. On

It is not a best approach but I solve it by creating another image asset and put iPhone X background image to its @3 area. Then In code I check If It is iPhone X screen, If yes I use image asset with x background, If other use default image asset.

    - (void) setBackgroundImage{
    // Load launch image
    NSString *launchImageName;
    if ([UIScreen mainScreen].bounds.size.height == 812){
        launchImageName = @"PublicBackground_X"; // iPhone X
    }
    else {
        launchImageName = @"PublicBackground"; // Other iPhones
    }

    UIImage *image = [UIImage imageNamed:launchImageName];
    [self.backgroundImage setImage: image];
}

EDIT: I don't know why I get bad reputation. None of other solutions worked for me. Clipping an Image shouldn't be acceptable If u have right resolution