bundle 存储资源(图片、xib、storyboard)
加载bundle有很多方式
.a静态库加载
NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"MNMediatorDemo" ofType:@"bundle"]];
NSString *alertImagePath = [bundle pathForResource:@"apple.png" ofType:nil];
self.imgView.image = [UIImage imageWithContentsOfFile:alertImagePath];
动态库加载方式
NSBundle *b = [NSBundle bundleForClass:[self class]];
NSString *path = [b pathForResource:@"MNMediatorDemo.bundle" ofType:nil];
NSString *imgPath = [[NSBundle bundleWithPath:path] pathForResource:@"apple.png" ofType:nil];
self.imgView.image = [UIImage imageWithContentsOfFile:imgPath];
网友评论