iOS获取启动图UIImage

得到对应当前屏幕尺寸的启动图

.h文件:

#import 

@interface GetLaunchImage : NSObject

+ (UIImage *)getTheLaunchImage;

@end

.m文件:

#import "GetLaunchImage.h"

@implementation GetLaunchImage

+ (UIImage *)getTheLaunchImage {
    CGSize viewSize = [UIScreen mainScreen].bounds.size;
    
    NSString *viewOrientation = nil;
    if (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) || ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait)) {
        viewOrientation = @"Portrait";
    }else {
        viewOrientation = @"Landscape";
    }
    
    NSString *launchImage = nil;
    
    NSArray *imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary *dict in imagesDict) {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        
        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]]) {
            launchImage = dict[@"UILaunchImageName"];
        }
    }
    
    return [UIImage imageNamed:launchImage];
}

@end

你可能感兴趣的:(iOS获取启动图UIImage)