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

原文地址: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];



☟☟可点击下方广告支持一下☟☟

最后修改:1970 年 01 月 01 日
请我喝杯可乐,请随意打赏: ☞已打赏列表