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];
}