读取Bundle 图片

项目中使用组件化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 图片)