priore

UIImage from icon app

Jun 5th, 2013
614
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. + (UIImage*)imageFromIconApp {
  2.    
  3.     NSString *iconName = nil;
  4.     NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
  5.    
  6.     NSArray *iconfiles = [info valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"];
  7.     if (iconfiles == nil || [iconfiles count] == 0) iconfiles = [info objectForKey:@"CFBundleIconFiles"];
  8.     if (iconfiles != nil && [iconfiles count] > 0) {
  9.         iconName = [iconfiles objectAtIndex:0];
  10.     } else {
  11.         iconName = [info objectForKey:@"CFBundleIconFile"];
  12.     }
  13.     return [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[iconName stringByReplacingOccurrencesOfString:@"@2x" withString:@""] ofType:@"png"]];
  14. }
RAW Paste Data