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

时间:2022-04-23 08:00:42

实例如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#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启动图的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:http://blog.csdn.net/ziyuzhiye/article/details/78909703