【发布时间】:2011-09-03 20:56:45
【问题描述】:
在我的应用中,我需要保存一张图片。即使设备处于横向模式,我也需要始终将图像保存为纵向。我正在检查设备是否处于横向模式,如果是,我想在保存为 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];
}
【问题讨论】:
-
你有没有想过这个问题?我在这里问的是基本相同的问题:stackoverflow.com/questions/20764623/… ...我希望您能提供任何帮助。 :)
标签: iphone ios uiimage rotation cgimageref