oc调用bundle图片文件
iOS 2020-02-16 20:49:35

 

PHP Code复制内容到剪贴板
  1. + (UIImage *)imageNamed:(NSString *)name ofBundle:(NSString *)bundleName {  
  2.     UIImage *image = nil;  
  3.     NSString *image_name = [NSString stringWithFormat:@"%@.png", name];  
  4.     NSString *resourcePath = [[NSBundle mainBundle] resourcePath];  
  5.     NSString *bundlePath = [resourcePath stringByAppendingPathComponent:bundleName];  
  6.     NSString *image_path = [bundlePath stringByAppendingPathComponent:image_name];;  
  7.     image = [[UIImage alloc] initWithContentsOfFile:image_path];  
  8.     return image;  
  9. }  

 

本文来自于:http://www.yoyo88.cn/study/swift/493.html

Powered by yoyo苏ICP备15045725号