旋转我试图旋转我的图像90度。它工作时没有旋转,但是当我旋转并翻译它不显示。我究竟做错了什么?图像旋转不正确
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"check" ofType:@"jpg"];
UIImage *newImage = [[UIImage alloc] initWithContentsOfFile:filePath];
UIGraphicsBeginImageContext(newImage.size);
//CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), newImage.size.width, 0);
//CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, newImage.size.width);
//CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
CGContextRotateCTM(UIGraphicsGetCurrentContext(), 90);
CGRect imageRect = CGRectMake(0, 0, newImage.size.height, newImage.size.width);
CGContextDrawImage(UIGraphicsGetCurrentContext(), imageRect, newImage.CGImage);
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
ImageView.image = viewImage;
支票本的其他问题http://stackoverflow.com/questions。/10307521/IOS-PNG-图像旋转90度 – tkanzakic
CGContextRotateCTM使用角度以弧度..所以M_PI_2为90度。 –