1

我想将旋转后的图像保存到照片库。我有一个 UIImageView 显示图像。我使用下面的代码片段来翻转图像。由于我转换了图像视图,旋转的图像确实会显示出来。但是在保存图像时,我得到了原始图像(未翻转)。如何保存翻转的图像?

CGAffineTransform transform =  CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
   image.transform = transform;
4

1 回答 1

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

希望这可以帮助 !!!

于 2012-08-28T05:07:02.537 回答