美文网首页
iOS获取bundle资源文件里面资源

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

作者: A_Yun | 来源:发表于2018-10-24 17:39 被阅读0次

//前五行 - 获取路径
//最后 - 获取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;

相关文章

网友评论

      本文标题:iOS获取bundle资源文件里面资源

      本文链接:https://www.haomeiwen.com/subject/zlpxtqtx.html