当前位置: 移动技术网 > 移动技术>移动开发>IOS > 用iOS代码获取APP启动页图片

用iOS代码获取APP启动页图片

2019年07月24日  | 移动技术网移动技术  | 我要评论

用代码获取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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网