资源文件配置
s.resource_bundles = {
'BundleName' => ['Resource/xib/*']
}
其中resource_bundles中的bundle文件是以数组的形式处理
其中BundleName是自定义的 后面是对应路径下的资源文件
可以把Resource下面对应不同的xib文件和image文件
资源文件加载
对于xib和image加载的方法有所不同
xib中分为view和viewController
NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"BundleName" withExtension:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithURL:bundleURL];
registerNib:[UINib nibWithNibName:@"XXCell" bundle:bundle]
image
NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"BundleName" withExtension:@"bundle"];
if (bundleURL) {
NSBundle *bundle = [NSBundle bundleWithURL:bundleURL];
NSInteger scale = [[UIScreen mainScreen] scale];
NSString *imgName = [NSString stringWithFormat:@"%@@%zdx.png", @"dadanmuban_select",scale];
imgV.image = [UIImage imageWithContentsOfFile:[bundle pathForResource:imgName ofType:nil]];
}
和xib相似 需要加载对应的scale 拼接成name 组合成bundle路径 以文件的形式加载对应的图片