以下是从Bundle中获取图片和language.string获取文字的方法
从Bundle中获取 文字的方法
#define GOOD_LOCALIZEDSTRING(name,comment) (NSLocalizedStringFromTableInBundle(name, @"Bundle中的文件名", [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"Bundle名" ofType:@"bundle"]], comment))
从Bundle中获取图片的方法
+(UIImage*)getImage
{
NSBundle* bundle=[self getResourcesBundle];
UIImage* img=[UIImage imageWithContentsOfFile:[bundle pathForResource:@"hello@2x" ofType:@"png"]];
img = [img stretchableImageWithLeftCapWidth:2 topCapHeight:img.size.height];
return img;
}
+(NSBundle*)getResourcesBundle
{
return [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"Bundle名" ofType:@"bundle"]];
}
取出Bundle下PNG文件名的数组 (inDirectory为子路径)
NSArray *array = [[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"GoodSDKResources" ofType:@"bundle"]] pathsForResourcesOfType:@"png" inDirectory:nil];