0
我有以下代碼UIImage的轉動偏移
- (void)ComputeRotationWithRadians:(CGFloat)rad {
CGFloat width = exportImage.size.width;
CGFloat height = exportImage.size.height;
UIGraphicsBeginImageContext(CGSizeMake(width, height));
CGContextRef ctxt = UIGraphicsGetCurrentContext();
CGContextScaleCTM(ctxt, 1.0, -1.0);
CGContextTranslateCTM(ctxt, 0.0, -exportImage.size.height);
CGContextRotateCTM(ctxt, rad);
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height), exportImage.CGImage);
exportImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[imageView setImage:exportImage];
}
的問題是發生了旋轉圍繞左下角,當它已經圍繞中心計算。無論如何要改變這個?
我已更改代碼,請參閱上文,仍然無效 – woody993 2009-11-18 07:43:55
您在旋轉之前仍在翻譯。您需要調用CGContextRotateCTM,然後調用CGContextTranslateCTM。 – fbrereto 2009-11-18 08:01:39
現在它只是在左上角做它 – woody993 2009-11-18 10:21:39