這個是加載bundle里面的
的圖片
+ (UIImage *)imageNamed:(NSString *)name ofBundle:(NSString *)bundleName {
UIImage *image = nil;
NSString *image_name = [NSString stringWithFormat:@"%@.png", name];
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSString *bundlePath = [resourcePath stringByAppendingPathComponent:bundleName];
NSString *image_path = [bundlePath stringByAppendingPathComponent:image_name];;
image = [[UIImage alloc] initWithContentsOfFile:image_path];
return image;
}
// 加載自定義名稱為Resources.bundle中對應images文件夾中的圖片
// 思路:從mainbundle中獲取resources.bundle
NSString *strResourcesBundle = [[NSBundle mainBundle] pathForResource:@"Resources" ofType:@"bundle"];
// 找到對應images夾下的圖片
NSString *strC = [[NSBundle bundleWithPath:strResourcesBundle] pathForResource:@"C" ofType:@"png" inDirectory:@"images"];
UIImage *imgC = [UIImage imageWithContentsOfFile:strC];
[imageView setImage:imgC];
//在.bundle文件里面添加圖片
將圖片文件直接拖拽進來
