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";

相关推荐
末代iOS程序员华仔2 小时前
iOS 语聊直播/聊天APP4.3条例被拒解决
flutter·ios·swift
2601_965798471 天前
Build a Fast, High-Ranking Restaurant Website with Rolanda Theme
开发语言·ios·swift
极客互动API1 天前
企业微信 iPad 协议消息接口开发:文本 / 图片 / 群发消息的统一封装
人工智能·ios·微信·机器人·企业微信·ipad
我血条子呢1 天前
iOS 软键盘遮挡底部输入框解决报告
ios
思盛iOS签名上架1 天前
为什么 iOS 需要签名?未签名 App 无法安装的底层逻辑
ios
Data_Journal2 天前
Golang 中解析 HTML 的指南
ios·iphone
jike_20262 天前
销售拜访记录APP推荐:客户沟通内容怎么快速整理?
ios·语音识别·iphone
00后程序员张2 天前
iOS 开发全流程需要哪些工具?编码、调试、构建、发布阶段选择
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
游戏开发爱好者83 天前
WebSocket 抓包怎么查看内容?从握手到消息帧完整解读
网络协议·计算机网络·网络安全·ios·adb·https·udp