首页 > 代码库 > 图片存储

图片存储

NSData *imageData;

        if (UIImagePNGRepresentation(imageToSave) == nil) {

            imageData = http://www.mamicode.com/UIImageJPEGRepresentation(imageToSave, 1);

        } else {

            imageData = http://www.mamicode.com/UIImagePNGRepresentation(imageToSave);

        }

        NSString *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];

        NSString *filePath = [documentPath stringByAppendingPathComponent:@"a.png"];

        [imageData writeToFile:filePath atomically:YES];

图片存储