ios CI/CD 持续集成 组件化专题三 IOS打包Bundle与加载Bundle中的图片

一、 读取 BundlePath

+ (NSString *)sdkPodsBundlePath {

    NSBundle *bundle = [NSBundle bundleForClass:[self class]];

    NSString *bundlePath = [bundle pathForResource:kSDKName ofType:@"bundle"];

    return bundlePath;

}

二 、读取bundle

+ (NSBundle *)sdkBundle {

    NSString *sdkPodsBundlePath = [QSGetResourceTool sdkPodsBundlePath];

    NSBundle *bd = nil;

    

    // SDK 自己使用时

    if (sdkPodsBundlePath) {

        NSBundle *bundle = [NSBundle bundleForClass:[self class]];

        NSString *bundlePath = [bundle pathForResource:kSDKName ofType:@"bundle"];

        NSBundle *bd = [NSBundle bundleWithPath:bundlePath];

    } else {

        bd = [NSBundle bundleForClass:[self class]];

    }

    return bd;

}

三、 读取bundle里面的图片

// 读取framework下的图片资源

+ (UIImage *)qs_imageSDKNamed:(NSString *)name {

    NSBundle *bd = [QSGetResourceTool sdkBundle];

    UIImage *image = [UIImage imageNamed:name inBundle:bd compatibleWithTraitCollection:nil];

    return image;

}

四、 使用

 UIImage * image = [UIImage qs_imageSDKNamed:@"xxx"];

最近更新

  1. TCP协议是安全的吗?

    2024-04-26 07:32:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-26 07:32:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-26 07:32:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-26 07:32:02       20 阅读

热门阅读

  1. 【C语言】typedef

    2024-04-26 07:32:02       14 阅读
  2. golang上传文件到ftp服务器

    2024-04-26 07:32:02       19 阅读
  3. 【计算机系统】

    2024-04-26 07:32:02       10 阅读
  4. 前端网络---网络安全

    2024-04-26 07:32:02       10 阅读
  5. Swift中TableView的编辑模式

    2024-04-26 07:32:02       14 阅读
  6. 稳扎稳打进入科研方向的三个阶段

    2024-04-26 07:32:02       16 阅读
  7. docker 使用和安装go

    2024-04-26 07:32:02       16 阅读
  8. Python基础:【习题系列】函数

    2024-04-26 07:32:02       15 阅读
  9. python爬取电影

    2024-04-26 07:32:02       15 阅读
  10. 2024年新版宝塔面板如何安装WordPress网站教程

    2024-04-26 07:32:02       16 阅读
  11. SSH远程直连服务器docker容器的jupyter

    2024-04-26 07:32:02       14 阅读
  12. 线程、线程组、线程池、锁、事务、分布式

    2024-04-26 07:32:02       13 阅读
  13. CentOS中安装python3

    2024-04-26 07:32:02       14 阅读
  14. go 环境安装

    2024-04-26 07:32:02       16 阅读