Skip to content

Instantly share code, notes, and snippets.

@priore
Created October 25, 2013 23:43
Show Gist options
  • Save priore/7163512 to your computer and use it in GitHub Desktop.
Save priore/7163512 to your computer and use it in GitHub Desktop.
UIImage from icon app
+ (UIImage*)imageFromIconApp {
NSString *iconName = nil;
NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
NSArray *iconfiles = [info valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"];
if (iconfiles == nil || [iconfiles count] == 0) iconfiles = [info objectForKey:@"CFBundleIconFiles"];
if (iconfiles != nil && [iconfiles count] > 0) {
iconName = [iconfiles objectAtIndex:0];
} else {
iconName = [info objectForKey:@"CFBundleIconFile"];
}
return [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[iconName stringByReplacingOccurrencesOfString:@"@2x" withString:@""] ofType:@"png"]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment