`
zhangyaochun
  • 浏览: 2565978 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

NSBundle

 
阅读更多

 

   NSBundle

 

   bundle 是一个目录,包含了图片等资源

 

   NSBundle *mainBundle = [NSBundle mainBundle];

 

   去目录里面读取文件,然后用 UIImageView 展示:

 

   通过 pathForResourceofType 来获取图片

 

   NSString *imagePath = [mainBundle pathForResource: @"***" ofType: @"png"];

 

  用 UIImage initWIthContentsOfFile 传入一个 imagePath

 

  UIImage *image = [[UIImage alloc] initWIthContentsOfFile: imagePath];

 

  用 UIImageView initWIthImage

 

  UIImageView *imageView = [[UIImageView alloc] initWithImage: image];

 

  [self.view addSubview: imageView];

 

 

  扩展:

 

   https://www.jianshu.com/p/34cda6a121db

 

   

分享到:
评论

相关推荐

    Apple NSBundle 使用说明文档

    Apple NSBundle 使用说明文档

    IOS UI学习教程之区分NSBundle和NSURL(读取文件、写入文件)

    本文实例为大家区分NSBundle和NSURL,具体实现内容如下 在项目的工程中添加一个文件,本例程添加的是aa.txt,文件的内容为百度: www.baidu.com,现在要使用NSBundle和NSURL分别去获取内容,代码如下: // 读取文件...

    iphone NSBundle 详解

    对于许多朋友来说 NSBundle比较陌生 本文详细介绍了bundle的使用,相信你一看便知 有iphone开发 兴趣的朋友加我qq 1748283579 注明csdn 加上自己工作经验,少于半年iphone开发经验的勿扰。。

    NSBundle读取图片 plist文件和txt文件

    http://blog.csdn.net/duxinfeng2010/article/category/1155790 博客有详细介绍

    自定义开关按钮(ios)

    例如,用图片代替:UIImage *normal_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_normal" ofType:@"png"]]; UIImage *normal_right = [[UIImage alloc] ...

    ios-MCTableView.zip

    MCtCell * cell = [[[NSBundle mainBundle]loadNibNamed:@"Order" owner:self options:nil]objectAtIndex:0]; cell.title.text = @"区头"; MCtCell * cell1 = [[[NSBundle mainBundle]loadNibNamed:@...

    Swift本地化的命令行工具xcmultilingual.zip

     return NSLocalizedString(rawValue, tableName: "Animal", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "")  }  static func keys() -> [String] {  return ["CAT", "DOG...

    从 NSBundle 获取 ap verion

    react-native-app-info 安装 $ npm install react-native-app-info --save $ rnpm link react-native-app-info 用法 var AppInfo = require('react-native-app-info'); console.log("应用版本号",AppInfo....

    OC Extension UIImage+FHXImage(图片扩展).zip

    NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; NSData *gifData = [NSData dataWithContentsOfFile:path]; return [UIImage sd_imageWithGIFData:gifData]; } OC Extension ...

    ios-datePickerView.zip

    self.datePicker =[[[NSBundle mainBundle] loadNibNamed:@"DatePickerView" owner:self options:0] lastObject]; self.datePicker.frame =CGRectMake(0, self.view.frame.size.height-260, self.view.frame.size...

    爱限免源代码

    NSString * path = [[NSBundle mainBundle] pathForResource:@"LoveFree" ofType:@"plist"]; NSDictionary * contentDic = [NSDictionary dictionaryWithContentsOfFile:path]; //获取所有的键值 NSArray *...

    全国省市县plist xml

    NSArray *ary = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ProvinceCityDistrict" ofType:@"plist"]]; for (int i = 0; i ; i ++) { NSDictionary *province = ary[i]; for...

    SDK1.6.2 demo.zip

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"res5" ofType:@"jpg"]; NSData *emoticonData = [NSData dataWithContentsOfFile:filePath]; UIImage *thumbImage = [UIImage imageNamed:@...

    tom猫游戏源码 iOS

    ios开发的tom,全部素材和源代码,战士... NSString *path = [[NSBundle mainBundle] pathForResource:imageName ofType:nil]; UIImage *image = [UIImage imageWithContentsOfFile:path]; arrayM[i] = image; };

    ios WKWebView 的使用和交互

    [queryItemArray addObject:[NSURLQueryItem queryItemWithName:@"version" value:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]]]; [urlComponents setQueryItems:...

    IOS获取当前版本号 Bundle ID等信息的方法详解

    1:获取bundle Id信息:[[NSBundle mainBundle]bundleIdentifier]; 2:获取版本号:[[[NSBundle mainBundle]infoDictionary] objectForKey:@”CFBundleShortVersionString”]; 3:获取build号:[[[NSBundle ...

    iOS Server 加载动态库 Demo (含Makefile)

    iOS界面app只可加载静态库,但server程序可以加载动态库。例子中含一简单实例,含Makefile。

    UIWebView的使用代码

    *localHTMLPageFilePath = [[NSBundle mainBundle] pathForResource:localHTMLPageName ofType:@"html"]; NSURL *localHTMLPageFileURL = [NSURL fileURLWithPath:localHTMLPageFilePath]; [webView ...

    initWithCoder与initWithFrame

    如果你的对象是UIViewControler的子类,那么你必须调用- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil;方法去调用NIB文件初始化自身,即使那没有使用nib文件也会调用这个函数...

Global site tag (gtag.js) - Google Analytics