1.先获取到APP沙盒中的图片路径path
2.然后将path作为参数,传入下面的方法里,进行图片保存到手机本地相册中。
#pragma mark 将截取到的头像保存到本地相册
- (void)saveHeaderImageWith:(NSString *)path
{
UIImage *img = [UIImage imageWithContentsOfFile:path];
[self saveImageToPhotos:img];
}
#pragma mark 保存图片
- (void)saveImageToPhotos:(UIImage*)savedImage
{
UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}
#pragma mark 系统的完成保存图片的方法
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
{
NSString *msg = nil ;
if (error != NULL) {
msg = @"保存图片失败" ;
} else {
msg = @"保存图片成功" ;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"保存图片结果提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
}