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, @"app_launch@2x.png", @"game", @"image")

imageV.image = img;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容