关于Bundle文件简单说明
2017-03-28 本文已影响0人
ZJ_偶尔上路
bundle文件简单理解就是一个专门放置、管理资源文件一个静态包,不参与项目的编译。
1、bundle文件的创建:
右键 -> New File -> iOS-> Resource -> Settings Bundle -> 为这个bundle文件起个名字 ->create -> 将你的资源文件拖进去 (ok);
2、bundle文件的使用:
我这里拖进去的是一个adsImage图片资源文件夹

获取图片资源:
bundle文件路径:
NSString * bundlePath = [[NSBundle mainBundle] pathForResource:@"AdvertiseImage" ofType:@"bundle"];
adsImage文件路径:
NSString * adsImagePath = [bundlePath stringByAppendingPathComponent:@"adsImage"];
图片资源:
UIImage *image = [UIImage imageWithContentsOfFile:[adsImagePath stringByAppendingPathComponent:@"ads1.png"]];
就这么简单.....