我想将旋转的图像保存到照片库。我有一个UIImageView,其中显示图像。我使用下面的代码片段来翻转图像。由于我变换了图像视图,因此显示旋转的图像。但是在保存图像的同时,我得到了原始图像(没有翻转)。如何保存翻转图像?
CGAffineTransform transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
image.transform = transform;
答案 0 :(得分:1)
只需截取图片或保存图片的截图即可保存,无论是旋转还是翻转......以下是一些代码....
-(IBAction)saveToPhotoGallery:(id)sender
{
UIGraphicsBeginImageContext(baseView.frame.size);
[baseView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *attachimage = [[UIImage alloc]initWithData:Data];
UIImage *viImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
attachimage = viImage;
UIImageWriteToSavedPhotosAlbum(viImage, nil, nil, nil);
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Save" message:@"Saved to photo gallery" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
[alert show];
}
}
希望这会有所帮助!!!