美文网首页
ios 获取自定义bundle资源小结

ios 获取自定义bundle资源小结

作者: baby_在海边 | 来源:发表于2017-11-21 16:15 被阅读0次

一、bundle 创建方式

   ##1、直接在finder里面创建一个文件夹,修改其后缀为.bundle
Snip20171121_1.png Snip20171121_2.png

2、直接Xcode创建

二、注意以上两种访问资源有坑

访问资源代码:

NSString *path = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"photo.bundle/photo_sel_photoPickerVc.png"];
        UIImage *image1 = [UIImage imageWithContentsOfFile:path];
或
        UIImage *image = [UIImage imageNamed:@"photo.bundle/photo_sel_photoPickerVc.png"];
  • 第一种方式创建的bundle访问不到相关的资源,第二种可以。原因如有大神知道,请告知,谢谢。

相关文章

网友评论

      本文标题:ios 获取自定义bundle资源小结

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