#pragma mark 先获取本地图片或者网络图片 - (void)saveHeaderImageWith:(NSString *)path { UIImage *img = [UIImage imageWithContentsOfFile:path]; //这里img也可以是从网络获取的图片 [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]; }
原文地址:https://www.cnblogs.com/liuzhi20101016/p/11775117.html
时间: 2024-10-09 06:43:08