图片存储

NSData *imageData;

        if (UIImagePNGRepresentation(imageToSave) == nil) {

            imageData = UIImageJPEGRepresentation(imageToSave, 1);

        } else {

            imageData = UIImagePNGRepresentation(imageToSave);

        }

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

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

        [imageData writeToFile:filePath atomically:YES];

posted @ 2014-11-20 11:04  回读(IOS)  阅读(183)  评论(0编辑  收藏  举报