静态framework加载bundle
方法1
-
把创建的bunle文件加载到framework中, evernotecid://DACA3747-3198-4F0B-8E91-B67AC80F3E8E/appyinxiangcom/13103255/ENResource/p3938
-
编译framework我们会在framework中看到bundle 文件
-
把framework 文件导入工程,
- 配置framewor工程
- 增加Copy Files
现在就可以在framework中的获取图片了,获取图片方式
NSString *path = [[NSBundle mainBundle] pathForResource:@"PPTPlay.framework/PPTRes" ofType: @"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:path];
UIImage *image = [UIImage imageNamed:@"pause" inBundle:bundle compatibleWithTraitCollection:nil];
方法2
把编译好的bundle 文件和framew文件同时导入到工程
NSString *path = [[NSBundle mainBundle] pathForResource:@"PPTRes" ofType: @"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:path];
UIImage *image = [UIImage imageNamed:@"pause" inBundle:bundle compatibleWithTraitCollection:nil];
加载过程中遇到了各种坑,加载不了图片,主要是对NSbundle还有一些不理解,大家可以去看一下下面的文章, iOS:NSBundle的一些理解 感谢