美文网首页
iOS获取LaunchImage图片

iOS获取LaunchImage图片

作者: 夜之海澜 | 来源:发表于2019-10-14 16:05 被阅读0次

    今天在项目中,需要将一个弹窗加载到启动图界面,由于我们本身无法控制启动图随时结束,所以我在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;
      }

    相关文章

      网友评论

          本文标题:iOS获取LaunchImage图片

          本文链接:https://www.haomeiwen.com/subject/ifwsyctx.html