Query launch image at runtime

后端 未结 2 1011
粉色の甜心
粉色の甜心 2020-12-18 07:24

I\'d like to have a nice start of my app by fading from the splash screen (UILaunchImageFile) into the main screen. Easy thing, I thought, just show an UIImageView with the

相关标签:
2条回答
  • 2020-12-18 07:38

    No, you can't do this automagically. Querying the device rotation and selecting an image based on that is perfectly fine.

    You really only need Portrait or Landscape in this situation though, assuming you are rotating your view properly.

    0 讨论(0)
  • 2020-12-18 08:00

    As already stated by Joshua you cannot, as far as I am aware.

    In case this might help someone else, if you are using asset catelogs the following code should provide the correct launch image for the current interface orientation.

    NSString *suffix = nil;
    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        suffix = [[UIScreen mainScreen] bounds].size.height >= 568.0f ? @"-568h@2x" : @"@2x";
    }
    else {
        UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
        suffix = UIInterfaceOrientationIsPortrait(orientation) ? @"-Portrait" : @"-Landscape";
        suffix = [UIScreen mainScreen].scale == 2.0 ? [suffix stringByAppendingString:@"@2x~ipad"] : [suffix stringByAppendingString:@"~ipad"];
    }
    
    NSString *launchImageName = [NSString stringWithFormat:@"LaunchImage-700%@.png",suffix];
    
    0 讨论(0)
提交回复
热议问题