获取Images.xcassets启动图、Images.xcassets Icon

Author Avatar
新风作浪 4月 09, 2018
  • 在其它设备中阅读本文章

获取Images.xcassets Icon文件

1
2
3
NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary];
NSString *icon = [[infoPlist valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"]lastObject];
UIImage *image = [UIImage imageNamed:icon];

获取Images.xcassets启动图

1
2
3
4
5
6
7
8
9
10
11
12
+ (NSString *)fetchLunchImageName
{
CGSize winSize = [UIScreen mainScreen].bounds.size;
NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
for (NSDictionary* dict in imagesDict) {
if(CGSizeEqualToSize(CGSizeFromString(dict[@"UILaunchImageSize"]),winSize))
{
return dict[@"UILaunchImageName"];
}
}
return nil;
}

App version

1
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

Bundleid

1
NSString *bundleid = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];