实例如下:

#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];

以上这篇iOS开发之获取LaunchImage启动图的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

02-03 02:33