美文网首页
静态framework加载bundle

静态framework加载bundle

作者: 开了那么 | 来源:发表于2020-07-22 18:16 被阅读0次
方法1
  • 把创建的bunle文件加载到framework中,


    DCFB96E2-E29E-410D-B682-A04107450332.png
  • 编译framework我们会在framework中看到bundle 文件


    Snip20200722_14.png
  • 把framework 文件导入工程,


    C55C13AD-89A1-46FD-A0FD-59DBE1760FB0.png
  • 配置framewor工程


    image.png
  • 增加Copy Files


    image.png

    现在就可以在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文件同时导入到工程


image.png

然后可以直接获取

    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的一些理解
感谢

相关文章

网友评论

      本文标题:静态framework加载bundle

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