//
// UIImage+GetImageFromBundle.h
// libDiskManage
//
// Created by chenyongyong on 14-1-13.
// Copyright (c) 2014年 chenyongyong. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIImage (GetImageFromBundle)
+ (UIImage *)imageNamedFromCustomBundle:(NSString *)imgName;
@end
//
// UIImage+GetImageFromBundle.m
// libDiskManage
//
// Created by chenyongyong on 14-1-13.
// Copyright (c) 2014年 chenyongyong. All rights reserved.
//
#import "UIImage+GetImageFromBundle.h"
@implementation UIImage (GetImageFromBundle)
+ (UIImage *)imageNamedFromCustomBundle:(NSString *)imgName
{
if (!imgName) return nil;
NSString *temp = [imgName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSArray *array = [temp componentsSeparatedByString:@"."];
NSString *bundlePath = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"GNImages.bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
// NSString *img_path = [bundle pathForResource:imgName ofType:@"png"];
NSString *img_path = [bundle pathForResource:[array objectAtIndex:0] ofType:[array objectAtIndex:(array.count - 1)]];
return [UIImage imageWithContentsOfFile:img_path];
}
@end