美文网首页
读取Bundle 图片

读取Bundle 图片

作者: coco_CC | 来源:发表于2018-06-28 16:46 被阅读162次

项目中使用组件化Coding管理代码了,图片放到Bundle中,读取图片时读取Bundle中的图片,因而不能使用[UIImage imageNamed:@""];,需要从Bundle中读取,也不是什么技术点,自己记录下~~

NSBundle *bundle = [NSBundle bundleForClass:self.class];
    NSURL *url = [bundle URLForResource:@"ACMediaFrame" withExtension:@"bundle"];
    NSBundle *imageBundle = [NSBundle bundleWithURL:url];
    UIImage *image = [UIImage imageNamed:@"deleteButton" inBundle:imageBundle compatibleWithTraitCollection:nil];

相关文章

网友评论

      本文标题:读取Bundle 图片

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