照片存入沙盒

2019-07-11  本文已影响0人  二猪哥
     // 本地沙盒目录
        NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *imageFilePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"image_%ld",(long)self.imageUrlsCount]];
        self.imageUrlsCount = self.picBigImages.count;
        [self.imageUrls addObject:imageFilePath];
        // 将取得的图片写入本地的沙盒中,其中0.5表示压缩比例,1表示不压缩,数值越小压缩比例越大
        BOOL success = [UIImageJPEGRepresentation(image, 0.5) writeToFile:imageFilePath  atomically:YES];
        if (success){
            NSLog(@"写入本地成功");
        }
上一篇 下一篇

猜你喜欢

热点阅读