开发者

iPhone dev: how to load images named the same from different groups

开发者 https://www.devze.com 2023-01-01 15:07 出处:网络
I am working on an iPhone project, and have two themes defined under different directories, with most files share th开发者_如何转开发e same names (like background.png, image1.png, image2.png, etc). I

I am working on an iPhone project, and have two themes defined under different directories, with most files share th开发者_如何转开发e same names (like background.png, image1.png, image2.png, etc). I have had them imported into xcode under different group names (group1, group2).

How do I tell UIImage to load an image from a given group, say, I want group1:background.png?

Thanks, Tim


Try this:

NSString *path = [[NSBundle mainBundle] pathForResource:@"image1" ofType:@"png" inDirectory:@"group1"];
[UIImage imageWithContentsOfFile: path];
0

精彩评论

暂无评论...
验证码 换一张
取 消