圖片保存到相冊??
Photos.framework 系統(tǒng)庫
#import <Photos/Photos.h>//系統(tǒng)頭文件
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
UIImage * images = [UIImage imageWithContentsOfFile:@""];
PHAssetChangeRequest *req = [PHAssetChangeRequest creationRequestForAssetFromImage:images];
}completionHandler:^(BOOL success, NSError * _Nullable error) {
保存失敗回調(diào)
}];
圖片壓縮??
UIImage *img = [UIImage imageWithContentsOfFile:imageName];
UIGraphicsBeginImageContext(CGSizeMake(width, height));
[img drawInRect:CGRectMake(0, 0, width, height)];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imgDataJpg = UIImageJPEGRepresentation(scaledImage,0.01);
NSString *base64 = [imgDataJpg base64Encoding];//這根據(jù)需求來可以不用轉(zhuǎn)base64字符串