美文网首页
在FrameWork中添加Assets管理的图片资源, 加载图片

在FrameWork中添加Assets管理的图片资源, 加载图片

作者: sws1314 | 来源:发表于2022-05-27 11:34 被阅读0次

在FrameWork中添加Assets管理的图片资源, 加载图片资源的方式

framework中的xcassets在framwork中直接加载图片:

#define SWSLiveModuleBundle (NSBundle *)([NSBundle bundleWithPath:[[NSBundle bundleForClass:self] pathForResource:@"LiveModule" ofType:@"xcassets"]] ?: [NSBundle bundleForClass:self])UIImage *img = [UIImage imageNamed:@"login_log" inBundle:SWSLiveModuleBundle compatibleWithTraitCollection:nil];

在外部使用framework中xcassets的图片资源:

#define SWSLiveModuleBundle (NSBundle *)[NSBundle bundleWithPath:([[NSBundle mainBundle] pathForResource:@"YCLiveModule" ofType:@"xcassets"] ?: ([[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Frameworks/YCLiveModule.framework"]))]UIImage *img = [UIImage imageNamed:@"login_log" inBundle:SWSLiveModuleBundle compatibleWithTraitCollection:nil];

相关文章

网友评论

      本文标题:在FrameWork中添加Assets管理的图片资源, 加载图片

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