读取bundle中的图片

    // 方法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中的图片)