iOS获取bundle资源文件里面资源

//前五行 - 获取路径
//最后 - 获取image

宏定义
/**
参1:image;
参2:图片名字;
参3:bundle名字;
参4:bundle资源文件里面文件夹名字

Friendly Tips:

(没有二级或多级,可传空)
(有二级就再拼接,它是一层一层进行查找,一般也不会有太多级 ^-^)

*/

#define GAIN_IMAGE(image,imgName,bundleName,secondBName){\

NSString * path = [[NSBundle mainBundle]pathForResource:bundleName ofType:@"bundle"];\

NSString *secondP = [path stringByAppendingPathComponent:secondBName];\

NSString *imgNameFile = [secondP stringByAppendingPathComponent:imgName];\

image = [UIImage imageWithContentsOfFile:imgNameFile];\

}\

example:

UIImageView * imageV ;
UIImage * img ;
GAIN_IMAGE(img, @"[email protected]", @"game", @"image")

imageV.image = img;

你可能感兴趣的:(iOS获取bundle资源文件里面资源)