当前位置:主页 > 移动开发 > iOS代码 >

iOS开发之获取LaunchImage启动图的实例

时间:2021-02-24 09:39:45 | 栏目:iOS代码 | 点击:

实例如下:

#define KYRect [UIScreen mainScreen].bounds

//获取启动图片
 CGSize viewSize = KYRect.size;
 //横屏请设置成 @"Landscape"
 NSString *viewOrientation = @"Portrait";
 NSString *launchImageName = 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"]])
  {
   launchImageName = dict[@"UILaunchImageName"];
  }
 }
 UIImage * launchImage = [UIImage imageNamed:launchImageName];
//将当前view的背景图设置为启动图片
 self.view.backgroundColor = [UIColor colorWithPatternImage:launchImage];

您可能感兴趣的文章:

相关文章