1。首先添加bundle到工程中,
在xcode中点击Project出现下面视图
点击Add Target
选择bundle
2。将资源添加到该Bundle中
在Build Phase中添加需要的资源
3。使用该Bundle
NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"BundleName" ofType:@"bundle"]];
NSString *imageName = [bundle pathForResource:@"close_button" ofType:@"png"];
NSLog(@"bundle:%@--image:%@",bundle,imageName);
UIImage *closeButton = [[UIImage alloc] initWithContentsOfFile:imageName];
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:closeButton];
[self.view addSubview:tempImageView];
tempImageView.frame = CGRectMake(100, 100, 43, 43);
更复杂的使用参考Apple官方文档