最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS獲取AppIcon and LaunchImage's name(app圖標(biāo)和啟動圖片名字)

 更新時間:2016年08月30日 09:27:29   投稿:mrr  
這篇文章主要介紹了iOS獲取AppIcon and LaunchImage's name(app圖標(biāo)和啟動圖片名字)的相關(guān)資料,非常不錯,具有參考借鑒價值,感興趣的朋友一起學(xué)習(xí)吧

在某種場景下,可能我們需要獲取app的圖標(biāo)名稱和啟動圖片的名稱。比如說app在前臺時,收到了遠(yuǎn)程通知但是通知欄是不會有通知提醒的,這時我想做個模擬通知提示,需要用到icon名稱;再比如在加載某個控制器時,想設(shè)置該控制器的背景圖片為啟動圖片,需要用到啟動圖片名稱。

  而事實上icon圖片放在系統(tǒng)AppIcon文件夾里,啟動圖片放在系統(tǒng)LaunchImage文件夾里,取這些圖片的名稱和其他一般資源圖片名稱不一樣。

  為了方便舉例子,咱們先簡單粗暴點

假設(shè)當(dāng)前項目只支持iPhone設(shè)備,并且只支持豎屏;而且當(dāng)前項目里已經(jīng)設(shè)置好了AppIcon圖標(biāo)和啟動圖片,

如何獲取icon圖標(biāo)名稱和啟動圖片名稱呢 ?

上代碼和打印日志:

/** 獲取app的icon圖標(biāo)名稱 */
- (void)getAppIconName{
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//獲取app中所有icon名字?jǐn)?shù)組
NSArray *iconsArr = infoDict[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
//取最后一個icon的名字
NSString *iconLastName = [iconsArr lastObject];
//打印icon名字
NSLog(@"iconsArr: %@", iconsArr);
NSLog(@"iconLastName: %@", iconLastName);
/*
打印日志:
iconsArr: (
AppIcon29x29,
AppIcon40x40,
AppIcon60x60
)
iconLastName: AppIcon60x60
*/
}
/** 獲取app的啟動圖片名稱,并設(shè)置為本控制器背景圖片 */
- (void)getLaunchImageName{
NSString *launchImageName = @""; //啟動圖片名稱變量
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
//獲取與當(dāng)前設(shè)備匹配的啟動圖片名稱
if (screenHeight == 480){ //4,4S
launchImageName = @"LaunchImage-700";
}
else if (screenHeight == 568){ //5, 5C, 5S, iPod
launchImageName = @"LaunchImage-700-568h";
}
else if (screenHeight == 667){ //6, 6S
launchImageName = @"LaunchImage-800-667h";
}
else if (screenHeight == 736){ // 6Plus, 6SPlus
launchImageName = @"LaunchImage-800-Landscape-736h";
}
if (launchImageName.length < 1) return;
//設(shè)備啟動圖片為控制器的背景圖片
UIImage *img = [UIImage imageNamed:launchImageName];
self.view.backgroundColor = [UIColor colorWithPatternImage:img]; 
}

打印當(dāng)前只支持iPhone設(shè)備并且只支持豎屏場景下的所有啟動圖片信息:

/** 打印app里面所有啟動圖片名稱信息 */
- (void)printAllLaunchImageInfo{
 NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
 //獲取所有啟動圖片信息數(shù)組
 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;
  UILaunchImageSize = "{375, 667}";
  },
  {
  UILaunchImageMinimumOSVersion = "7.0";
  UILaunchImageName = "LaunchImage-700";
  UILaunchImageOrientation = Portrait;
  UILaunchImageSize = "{320, 480}";
  },
  {
  UILaunchImageMinimumOSVersion = "7.0";
  UILaunchImageName = "LaunchImage-700-568h";
  UILaunchImageOrientation = Portrait;
  UILaunchImageSize = "{320, 568}";
  }
 )
 */
}

看到了,項目AppIcon圖標(biāo)和啟動圖片信息,都可以從 [[NSBundle mainBundle] infoDictionary] 獲得,當(dāng)前這里面還包含了app的其他信息如版本、app名稱、設(shè)備類型、支持方向。。。

打印所有信息看看:

/** 打印app工程配置信息 */
- (void)printInfoDictionary{
 NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
 NSLog(@"%@", infoDict);
 /*
 打印日志:
 {
  BuildMachineOSBuild = 15G31;
  CFBundleDevelopmentRegion = en;
  CFBundleExecutable = TanTest;
  CFBundleIcons = {
  CFBundlePrimaryIcon =  {
   CFBundleIconFiles =  (
   AppIcon29x29,
   AppIcon40x40,
   AppIcon60x60
   );
  };
  };
  CFBundleIdentifier = "net.tan.xxx";
  CFBundleInfoDictionaryVersion = "6.0";
  CFBundleInfoPlistURL = "Info.plist -- file:///Users/PX/Library/Developer/CoreSimulator/Devices/7020368B-C160-42C0-B3C5-5F958FA82EF5/data/Containers/Bundle/Application/77D8C333-A6AF-4183-B79A-A5BEDCD08E1A/TanTest.app/";
  CFBundleName = TanTest;
  CFBundleNumericVersion = 16809984;
  CFBundlePackageType = APPL;
  CFBundleShortVersionString = "1.0";
  CFBundleSignature = "????";
  CFBundleSupportedPlatforms = (
  iPhoneSimulator
  );
  CFBundleVersion = 1;
  DTCompiler = "com.apple.compilers.llvm.clang.1_0";
  DTPlatformBuild = "";
  DTPlatformName = iphonesimulator;
  DTPlatformVersion = "9.3";
  DTSDKBuild = 13E230;
  DTSDKName = "iphonesimulator9.3";
  DTXcode = 0731;
  DTXcodeBuild = 7D1014;
  LSRequiresIPhoneOS = 1;
  MinimumOSVersion = "6.0";
  UIDeviceFamily = (
  );
  UILaunchImageFile = LaunchImage;
  UILaunchImages = (
  {
   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;
   UILaunchImageSize = "{375, 667}";
  },
  {
   UILaunchImageMinimumOSVersion = "7.0";
   UILaunchImageName = "LaunchImage-700";
   UILaunchImageOrientation = Portrait;
   UILaunchImageSize = "{320, 480}";
  },
  {
   UILaunchImageMinimumOSVersion = "7.0";
   UILaunchImageName = "LaunchImage-700-568h";
   UILaunchImageOrientation = Portrait;
   UILaunchImageSize = "{320, 568}";
  }
  );
  UILaunchStoryboardName = LaunchScreen;
  UIMainStoryboardFile = Main;
  UIRequiredDeviceCapabilities = (
  armv7
  );
  UISupportedInterfaceOrientations = (
  UIInterfaceOrientationPortrait
  );
 }
 */
}

---------- 接下來我們再來在app既支持iPhone和iPad設(shè)備,又支持橫屏和豎屏?xí)r,AppIcon和LaunchImage是怎樣的以及如何獲取 ---

先上兩張圖,再上測試代碼:

測試代碼:

1、獲取AppIcon所有icon圖標(biāo)名稱

/** 支持iPhone和iPad, 獲取app的icon圖標(biāo)名稱 */
- (void)getAppIconName{
 NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
 //獲取app中所有icon名字?jǐn)?shù)組
 NSArray *iconsArr = infoDict[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
 //取最后一個icon的名字
 NSString *iconLastName = [iconsArr lastObject];
 //打印icon名字
 NSLog(@"iconsArr: %@", 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
 */
}

2、獲取在支持iPhone和iPad開發(fā),支持橫屏和豎屏?xí)r,獲取啟動圖片,并設(shè)為背景圖片代碼

(iPhone設(shè)備只有在Plus, 即5.5英寸才有豎屏和橫屏兩套圖片,其他4、5、6豎屏橫屏共用一張啟動圖片)

/** 
 支持iPhone和iPad, 支持橫屏、豎屏,
 獲取app的啟動圖片名稱,并設(shè)置為本控制器背景圖片
 */
- (void)getLaunchImageName{
 NSString *launchImageName = @""; //啟動圖片名稱變量
 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; //屏幕高度
 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; //屏幕寬度
 //設(shè)備界面方向
 UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
 BOOL isPortrait = UIInterfaceOrientationIsPortrait(orientation);// 是否豎屏
 BOOL isLandscape = UIInterfaceOrientationIsLandscape(orientation);//是否橫屏
 //獲取與當(dāng)前設(shè)備匹配的啟動圖片名稱
 //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;
 //設(shè)備啟動圖片為控制器的背景圖片
 UIImage *img = [UIImage imageNamed:launchImageName];
 self.view.backgroundColor = [UIColor colorWithPatternImage:img];
}

3、打印出所有啟動圖片信息

/** 打印app里面所有啟動圖片名稱信息 */
- (void)printAllLaunchImageInfo{
 NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
 //獲取所有啟動圖片信息數(shù)組
 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;
  UILaunchImageSize = "{375, 667}";
  },
  {
  UILaunchImageMinimumOSVersion = "7.0";
  UILaunchImageName = "LaunchImage-700";
  UILaunchImageOrientation = Portrait;
  UILaunchImageSize = "{320, 480}";
  },
  {
  UILaunchImageMinimumOSVersion = "7.0";
  UILaunchImageName = "LaunchImage-700-568h";
  UILaunchImageOrientation = Portrait;
  UILaunchImageSize = "{320, 568}";
  },
  {
  UILaunchImageMinimumOSVersion = "7.0";
  UILaunchImageName = "LaunchImage-700-Portrait";
  UILaunchImageOrientation = Portrait;
  UILaunchImageSize = "{768, 1024}";
  },
  {
  UILaunchImageMinimumOSVersion = "7.0";
  UILaunchImageName = "LaunchImage-700-Landscape";
  UILaunchImageOrientation = Landscape;
  UILaunchImageSize = "{768, 1024}";
  }
 )
 */
}

4、打印所有配置信息

/** 打印app工程配置信息 */
- (void)printInfoDictionary{
 NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
 NSLog(@"%@", infoDict);
 /*
 打印日志:
 {
 BuildMachineOSBuild = 15G31;
 CFBundleDevelopmentRegion = en;
 CFBundleExecutable = TanTest;
 CFBundleIcons = {
  CFBundlePrimaryIcon =  {
  CFBundleIconFiles =  (
       AppIcon29x29,
       AppIcon40x40,
       AppIcon60x60,
       AppIcon76x76,
       "AppIcon83.5x83.5"
       );
  };
 };
 CFBundleIdentifier = "net.tan.xxx";
 CFBundleInfoDictionaryVersion = "6.0";
 CFBundleInfoPlistURL = "Info.plist -- file:///Users/PX/Library/Developer/CoreSimulator/Devices/3246F9AE-1D73-4E4F-8DDF-F591DBE64F63/data/Containers/Bundle/Application/7DD6C793-F882-43CF-9897-1433411289E6/TanTest.app/";
 CFBundleName = TanTest;
 CFBundleNumericVersion = 16809984;
 CFBundlePackageType = APPL;
 CFBundleShortVersionString = "1.0";
 CFBundleSignature = "????";
 CFBundleSupportedPlatforms = (
      iPhoneSimulator
      );
 CFBundleVersion = 1;
 DTCompiler = "com.apple.compilers.llvm.clang.1_0";
 DTPlatformBuild = "";
 DTPlatformName = iphonesimulator;
 DTPlatformVersion = "9.3";
 DTSDKBuild = 13E230;
 DTSDKName = "iphonesimulator9.3";
 DTXcode = 0731;
 DTXcodeBuild = 7D1014;
 LSRequiresIPhoneOS = 1;
 MinimumOSVersion = "9.0";
 UIDeviceFamily = (
    1,
    );
 UILaunchImageFile = LaunchImage;
 UILaunchImages = (
    {
     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;
     UILaunchImageSize = "{375, 667}";
    },
    {
     UILaunchImageMinimumOSVersion = "7.0";
     UILaunchImageName = "LaunchImage-700";
     UILaunchImageOrientation = Portrait;
     UILaunchImageSize = "{320, 480}";
    },
    {
     UILaunchImageMinimumOSVersion = "7.0";
     UILaunchImageName = "LaunchImage-700-568h";
     UILaunchImageOrientation = Portrait;
     UILaunchImageSize = "{320, 568}";
    },
    {
     UILaunchImageMinimumOSVersion = "7.0";
     UILaunchImageName = "LaunchImage-700-Portrait";
     UILaunchImageOrientation = Portrait;
     UILaunchImageSize = "{768, 1024}";
    },
    {
     UILaunchImageMinimumOSVersion = "7.0";
     UILaunchImageName = "LaunchImage-700-Landscape";
     UILaunchImageOrientation = Landscape;
     UILaunchImageSize = "{768, 1024}";
    }
    );
 UILaunchStoryboardName = LaunchScreen;
 UIMainStoryboardFile = Main;
 UIRequiredDeviceCapabilities = (
      armv7
      );
 UISupportedInterfaceOrientations = (
      UIInterfaceOrientationPortrait,
      UIInterfaceOrientationLandscapeLeft,
      UIInterfaceOrientationLandscapeRight
      );
 }*/
}

以上所述是小編給大家介紹的iOS獲取AppIcon and LaunchImage's name(app圖標(biāo)和啟動圖片名字),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • RocketMQ?Broker消息如何刷盤源碼解析

    RocketMQ?Broker消息如何刷盤源碼解析

    這篇文章主要為大家介紹了RocketMQ?Broker消息如何刷盤源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • SpringBoot+SpringBatch+Quartz整合定時批量任務(wù)方式

    SpringBoot+SpringBatch+Quartz整合定時批量任務(wù)方式

    這篇文章主要介紹了SpringBoot+SpringBatch+Quartz整合定時批量任務(wù)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • Java判斷字符串為空、字符串是否為數(shù)字

    Java判斷字符串為空、字符串是否為數(shù)字

    這篇文章主要介紹了Java判斷字符串為空、字符串是否為數(shù)字,其中數(shù)字的判斷介紹了3種方法,需要的朋友可以參考下
    2014-06-06
  • 基于String不可變字符與StringBuilder可變字符的效率問題

    基于String不可變字符與StringBuilder可變字符的效率問題

    這篇文章主要介紹了String不可變字符與StringBuilder可變字符的效率問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • Java工具類之@RequestMapping注解

    Java工具類之@RequestMapping注解

    今天帶大家來學(xué)習(xí)Java工具類,文中對注解@RequestMapping作了非常詳細(xì)的介紹,對正在學(xué)習(xí)java的小伙伴們很有幫助,需要的朋友可以參考下
    2021-05-05
  • java中幾種常見的排序算法總結(jié)

    java中幾種常見的排序算法總結(jié)

    大家好,本篇文章主要講的是java中幾種常見的排序算法總結(jié),感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下
    2022-01-01
  • java return用法實例詳解

    java return用法實例詳解

    在本篇文章里小編給大家整理的是關(guān)于java return用法以及相關(guān)知識點總結(jié),需要的朋友們參考下。
    2019-08-08
  • Mybatis的幾種傳參方式詳解

    Mybatis的幾種傳參方式詳解

    這篇文章主要介紹了Mybatis的幾種傳參方式詳解,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-09-09
  • java實現(xiàn)銀行ATM管理系統(tǒng)

    java實現(xiàn)銀行ATM管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了java實現(xiàn)銀行ATM管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • java發(fā)送heartbeat心跳包(byte轉(zhuǎn)16進(jìn)制)

    java發(fā)送heartbeat心跳包(byte轉(zhuǎn)16進(jìn)制)

    這篇文章主要介紹了java發(fā)送heartbeat心跳包(byte轉(zhuǎn)16進(jìn)制),需要的朋友可以參考下
    2014-05-05

最新評論

张北县| 鄂托克前旗| 辽中县| 资阳市| 江陵县| 济源市| 宣威市| 宾阳县| 桦南县| 闵行区| 辽源市| 衢州市| 湖口县| 扶绥县| 尼勒克县| 义马市| 江源县| 山东省| 微博| 日土县| 安庆市| 达日县| 洛宁县| 宜良县| 承德市| 抚州市| 镇康县| 秦皇岛市| 昔阳县| 八宿县| 金门县| 高邑县| 桦甸市| 浦城县| 静乐县| 卓资县| 澎湖县| 崇明县| 扶余县| 河津市| 化德县|