// 方法1
UIImage *image = [UIImage imageNamed:@"MyTest.bundle/Test"];
// 方法2
NSString *file1 = [[NSBundle mainBundle] pathForResource:@"MyTest.bundle/Test" ofType:@"png"];
UIImage *image1 = [UIImage imageWithContentsOfFile:file1];
// 方法3
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyTest" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:path];
NSString *file2 = [bundle pathForResource:@"Test" ofType:@"png"];
UIImage *image2 = [UIImage imageWithContentsOfFile:file2];
加载bundle中的图片
最新推荐文章于 2022-07-19 16:25:50 发布