星空网 > 软件开发 > 操作系统

用代码获取APP启动页图片

用代码获取APP启动页图片

用代码获取APP启动页图片images/loading.gif' data-original="http://images2015.cnblogs.com/blog/607542/201608/607542-20160811224217609-2017512391.gif" />

 

源码 - swift

//// AppleSystemService.swift// Swift-Animations//// Created by YouXianMing on 16/8/11.// Copyright © 2016年 YouXianMing. All rights reserved.//import UIKitclass 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

 




原标题:用代码获取APP启动页图片

关键词:图片

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

Amazon Store 高配版教程来啦!转化提升100%!:https://www.ikjzd.com/articles/133460
12封常见亚马逊售后客服邮件模板:https://www.ikjzd.com/articles/133461
这五个方法帮你减少亚马逊广告预算:https://www.ikjzd.com/articles/133462
欧洲多城封锁,“双11”剁手却不含糊:https://www.ikjzd.com/articles/133464
注意了!亚马逊连发两条新规,事关库存与禁售,卖家当心!:https://www.ikjzd.com/articles/133466
拜登当选总统,对亚马逊卖家有什么影响?:https://www.ikjzd.com/articles/133467
美众议院对TikTok“动手”,下一步该怎么在TikTok上营销?:https://www.kjdsnews.com/a/1836587.html
速卖通在韩国争议不断,投诉量激增两倍:https://www.kjdsnews.com/a/1836588.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流