今天在项目中,需要将一个弹窗加载到启动图界面,由于我们本身无法控制启动图随时结束,所以我在launch方法中,给window的rootviewcontroller添加了一个图片,这个图片就是取自我们的启动图,这样就会有一种启动图一直未消失的假象。获取图片的方法如下:
- (UIImage *)getLaunchImage {
UIImage *launchImg = [[UIImage alloc] init];
NSString *orientation = @"";
CGSize screenSize = [UIScreen mainScreen].bounds.size;
UIInterfaceOrientation statusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (statusBarOrientation == UIInterfaceOrientationLandscapeLeft || statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
orientation = @"Landscape";
} else {
orientation = @"Portrait";
}
NSArray *imgsInfoArr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UILaunchImages"];
for (NSDictionary *info in imgsInfoArr) {
CGSize imgSize = CGSizeFromString(info[@"UILaunchImageSize"]);
if (CGSizeEqualToSize(imgSize, screenSize) && [orientation isEqualToString:info[@"UILaunchImageOrientation"]] ) {
launchImg = [UIImage imageNamed:info[@"UILaunchImageName"]];
}
}
return launchImg;
}
网友评论