Objective-C Tips & Trick - Prioregroup.com
[Objective-C] UIImage from icon app
       
back

+ (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"]];
}






Copyright © 1996-2018 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.
prioregroup.com