IPA PNG图片转换

- (void)loadAllBundleImage
{
    NSArray * imagesPath = [NSBundle pathsForResourcesOfType:@"png" inDirectory:[[NSBundle mainBundle]bundlePath]];
    for (NSString * a in imagesPath) {
        NSData * idata =UIImagePNGRepresentation([UIImage imageWithContentsOfFile:a]);
        [self writeApplicationData: idata toFile: [a lastPathComponent]];
    }
}
- (BOOL)writeApplicationData:(NSData *)data toFile:(NSString *)fileName 
{
    NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    if (!documentsDirectory) {
        NSLog(@"Documents directory not found!");
        return NO;
    }
    NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName];
    return ([data writeToFile:appFile atomically:YES]);
}
posted @ 2012-06-24 10:55  Ethan_村长  阅读(979)  评论(1编辑  收藏  举报