一、 读取 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";