用iOS代碼獲取APP啟動頁圖片
用代碼獲取APP啟動頁圖片
// // 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
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS11實(shí)現(xiàn)App內(nèi)自動連接Wi-Fi的方法
這篇文章主要給大家介紹了關(guān)于iOS11實(shí)現(xiàn)App內(nèi)自動連接Wi-Fi的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-10-10IOS如何在Host App 與 App Extension 之間發(fā)送通知
這篇文章主要介紹了IOS如何在Host App 與 App Extension 之間發(fā)送通知 的相關(guān)資料,需要的朋友可以參考下2016-03-03查看iOS已上架App的Crash信息定位、應(yīng)對處理方式的實(shí)例
下面小編就為大家?guī)硪黄榭磇OS已上架App的Crash信息定位、應(yīng)對處理方式的實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12iOS實(shí)現(xiàn)卡片式滾動效果 iOS實(shí)現(xiàn)電影選片效果
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)卡片式滾動效果,實(shí)現(xiàn)電影選片效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-02-02詳解iOS中Button按鈕的狀態(tài)和點(diǎn)擊事件
這篇文章先是給大家介紹iOS中Button按鈕的狀態(tài),而后又詳細(xì)介紹了iOS中按鈕點(diǎn)擊事件處理方式,本文介紹的很詳細(xì),有需要的朋友們可以參考借鑒,下面來一起看看吧。2016-09-09iOS開發(fā)中實(shí)現(xiàn)新聞圖片的無限循環(huán)展示的方法
這篇文章主要介紹了iOS開發(fā)中實(shí)現(xiàn)新聞圖片的無限循環(huán)展示的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-12-12