用代码获取APP启动页图片

源码 - swift

//
// AppleSystemService.swift
// Swift-Animations
//
// Created by YouXianMing on 16/8/11.
// Copyright © 2016年 YouXianMing. All rights reserved.
// import UIKit class AppleSystemService : NSObject { /**
Get the lauch image. - returns: The lauch image.
*/
class func launchImage() -> UIImage { var lauchImage : UIImage!
var viewOrientation : String!
let viewSize = UIScreen.mainScreen().bounds.size
let orientation = UIApplication.sharedApplication().statusBarOrientation if orientation == .LandscapeLeft || orientation == .LandscapeRight { viewOrientation = "Landscape" } else { viewOrientation = "Portrait"
} let imagesInfoArray = NSBundle.mainBundle().infoDictionary!["UILaunchImages"]
for dict : Dictionary <String, String> in imagesInfoArray as! Array { let imageSize = CGSizeFromString(dict["UILaunchImageSize"]!)
if CGSizeEqualToSize(imageSize, viewSize) && viewOrientation == dict["UILaunchImageOrientation"]! as String { lauchImage = UIImage(named: dict["UILaunchImageName"]!)
}
} return lauchImage
}
}

源码 - Objective-C

//
// AppleSystemService.h
// AppleSystemService
//
// Created by YouXianMing on 16/7/2.
// Copyright © 2016年 YouXianMing. All rights reserved.
// #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h> @interface AppleSystemService : NSObject /**
* Get the lauch image.
*
* @return The lauch image.
*/
+ (UIImage *)launchImage; @end
//
// AppleSystemService.m
// AppleSystemService
//
// Created by YouXianMing on 16/7/2.
// Copyright © 2016年 YouXianMing. All rights reserved.
// #import "AppleSystemService.h" @implementation AppleSystemService + (UIImage *)launchImage { UIImage *lauchImage = nil;
NSString *viewOrientation = nil;
CGSize viewSize = [UIScreen mainScreen].bounds.size;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { viewOrientation = @"Landscape"; } else { viewOrientation = @"Portrait";
} NSArray *imagesDictionary = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
for (NSDictionary *dict in imagesDictionary) { CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]]) { lauchImage = [UIImage imageNamed:dict[@"UILaunchImageName"]];
}
} return lauchImage;
} @end

最新文章

  1. Python namedtuple
  2. 利用nodejs+phantomjs+casperjs采集淘宝商品的价格
  3. IT公司100题-9-判断整数序列是不是二元查找树的后序遍历结果
  4. linux-redhat5找回root密码
  5. MSP430常见问题之看门狗及定时器类
  6. TCP/IP 教程
  7. JAVA GC之标记 第五节
  8. C# backgroundworker使用方法
  9. Mac 终端Terminal光标移动快捷键
  10. opencv 进行图像的花屏检测(模糊检测)
  11. TextView展示富文本时emoj或图片和文字不对齐的解决方案
  12. JNA调用DLL(入门):让你一眼就学会
  13. ps教程
  14. 微信JS API PHP类
  15. maven(视频学习)
  16. .net WebService 大数据量时性能的提高
  17. 微信小程序(2)——新建页面
  18. leetcode513
  19. PXC 避免加入集群时发生SST
  20. Fiddler-常用技巧

热门文章

  1. CAS5.2x单点登录(二)cas服务器连接数据库
  2. JS 解析JSON实现导序
  3. Linux 配置mail发送邮件
  4. 使用 Maven 来管理项目 &amp; 从 0 开始搭建 Maven 项目
  5. BZOJ.5312.冒险(线段树)
  6. android 项目上传SVN不需要上传的文件
  7. gdb 调试及优化
  8. 媒体查询@media query
  9. [Java]MyBatis框架
  10. Codeforces Round #368 (Div. 2) B. Bakery 水题