如果文章对您有用,麻烦顺手点一下文章的广告吧~

东东

iOS使用本地图片创建imageview的三种方式
今天刚好就看到了这三种方式,感觉肯定有人用的着就转载过来了原文地址:http://blog.sina.com.cn...
扫描右侧二维码阅读全文
07
2015/02

iOS使用本地图片创建imageview的三种方式

今天刚好就看到了这三种方式,感觉肯定有人用的着就转载过来了

原文地址:http://blog.sina.com.cn/s/blog_6a99c8bc01011ppj.html

1。直接拖进工程+copy

image = [UIImage imageNamed: @"fakeXcode.png"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"fakeXcode" ofType:@"png"];
image = [[UIImage alloc]initWithContentsOfFile:path];


2.把文件夹拖进工程目录,然后拖进工程,create folder references for any added folder,(蓝色文件夹res)

image = [UIImage imageNamed: @"res/fakeXcode.png"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"fakeXcode.png" ofType:nil inDirectory:@"res"];
image = [[UIImage alloc]initWithContentsOfFile:path];



3.创建bundle,把资源放进bundle(白色bundle,res.bundle)

image = [UIImage imageNamed: @"es.bundle/fakeXcode.png"];
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"res.bundle/fakeXcode.png"];
image = [[UIImage alloc]initWithContentsOfFile:path];


Last modification:January 1st, 1970 at 08:00 am
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment