Created
October 25, 2013 23:43
-
-
Save priore/7163512 to your computer and use it in GitHub Desktop.
UIImage from icon app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (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