NSBundle 资源获取
作者:
SamCheck | 来源:发表于
2018-07-06 10:32 被阅读10次
获取.bundle包中的资源
NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"Resources" withExtension:@"bundle"]];
//获取的文件在bundle的根目录
NSString *resource = [bundle resourcePath];
//获取的文件在bundle的根目录中test/wss子目录中
resource = [bundle pathForAuxiliaryExecutable:@"test/wss"];
NSString *pngPath = [resource stringByAppendingPathComponent:@"ddddd.png"];
UIImage *img1 = [UIImage imageNamed: pngPath];//加载到缓存
UIImage *img2 = [UIImage imageWithContentsOfFile: pngPath];//只加载本地,不到缓存中
本文标题:NSBundle 资源获取
本文链接:https://www.haomeiwen.com/subject/ddppuftx.html
网友评论