设为首页 加入收藏

TOP

iOS获取app图标和启动图片名字(AppIcon and LaunchImage's name)(三)
2017-10-13 09:46:27 】 浏览:12270
Tags:iOS 获取 app 图标 启动 图片 名字 AppIcon and LaunchImage' name
: %@
", iconsArr); NSLog(@"iconLastName: %@", iconLastName); /* 打印日志(29pt和40pt iPhone和iPad都用到;60pt --- iPhone, 76pt和83.5pt --- iPad): iconsArr: ( AppIcon29x29, AppIcon40x40, AppIcon60x60, AppIcon76x76, "AppIcon83.5x83.5" ) iconLastName: AppIcon83.5x83.5 */ } View Code

 

2、获取在支持iPhone和iPad开发,支持横屏和竖屏时,获取启动图片,并设为背景图片代码

     (iPhone设备只有在Plus, 即5.5英寸才有竖屏和横屏两套图片,其他4、5、6竖屏横屏共用一张启动图片)

/** 
 支持iPhone和iPad, 支持横屏、竖屏,
 获取app的启动图片名称,并设置为本控制器背景图片
 */
- (void)getLaunchImageName{
    
    NSString *launchImageName = @"";  //启动图片名称变量
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; //屏幕高度
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; //屏幕宽度
    
    //设备界面方向
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    
    BOOL isPortrait = UIInterfaceOrientationIsPortrait(orientation);// 是否竖屏
    BOOL isLandscape = UIInterfaceOrientationIsLandscape(orientation);//是否横屏
    
    //获取与当前设备匹配的启动图片名称
    //4、4S 竖屏,横屏
    if ((isPortrait && screenHeight == 480) || (isLandscape && screenWidth == 480)){
        launchImageName = @"LaunchImage-700";
    }
    //5、5C、5S、iPod 竖屏,横屏
    else if ((isPortrait && screenHeight == 568) || (isLandscape && screenWidth == 568)){
        launchImageName = @"LaunchImage-700-568h";
    }
    //6、6S 竖屏,横屏
    else if ((isPortrait && screenHeight == 667) || (isLandscape && screenWidth == 667)){
        launchImageName = @"LaunchImage-800-667h";
    }
    //6Plus、6SPlus竖屏
    else if (isPortrait && screenHeight == 736){
        launchImageName = @"LaunchImage-800-Portrait-736h";
    }
    //6Plus、6SPlus 横屏
    else if (isLandscape && screenWidth == 736){
        launchImageName = @"LaunchImage-800-Landscape-736h";
    }
    //iPad 竖屏
    else if (isPortrait && screenHeight == 1024){
        launchImageName = @"LaunchImage-700-Portrait";
    }
    //iPad 横屏
    else if (isLandscape && screenWidth == 1024){
        launchImageName = @"LaunchImage-700-Landscape";
    }
    
    if (launchImageName.length < 1) return;
    
    //设备启动图片为控制器的背景图片
    UIImage *img = [UIImage imageNamed:launchImageName];
    self.view.backgroundColor = [UIColor colorWithPatternImage:img];
}
View Code

 

3、打印出所有启动图片信息

/** 打印app里面所有启动图片名称信息 */
- (void)printAllLaunchImageInfo{
    
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    
    //获取所有启动图片信息数组
    NSArray *launchImagesArr = infoDict[@"UILaunchImages"];
    
    NSLog(@"launchImagesArr: %@", launchImagesArr);
    /*
     打印日志:启动图片的名字是固定的
     launchImagesArr: (
         {
             UILaunchImageMinimumOSVersion = "8.0";
             UILaunchImageName = "LaunchImage-800-Portrait-736h";
             UILaunchImageOrientation = Portrait;
             UILaunchImageSize = "{414, 736}";
         },
         {
             UILaunchImageMinimumOSVersion = "8.0";
             UILaunchImageName = "LaunchImage-800-Landscape-736h";
             UILaunchImageOrientation = Landscape;
             UILaunchImageSize = "{414, 736}";
         },
         {
             UILaunchImageMinimumOSVersion = "8.0";
             UILaunchImageName = "LaunchImage-800-667h";
             UILaunchImageOrientation = Portrait;
             UILaunchIm
首页 上一页 1 2 3 4 5 下一页 尾页 3/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇iOS 直播-网速监控 下一篇你真的了解UIScrollView吗?

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目