在我的应用程序中,我需要保存图像。即使设备处于横向模式,我也需要始终将图像保存为纵向。我正在检查设备是否处于横向模式,如果是,我想在保存为 PNG 之前旋转我的图像。谁能帮我解决这个问题?
-(void) saveImage {
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
//// need to rotate it here
}
NSData *data = UIImagePNGRepresentation (viewImage);
[data writeToFile:savePath atomically:YES];
}