【发布时间】:2016-04-06 10:02:29
【问题描述】:
我正在根据比例值旋转 UIImage。我的 Scale 和 Rotation 运行良好,但问题是旋转 uiimage 后,图像大小(宽度和高度)正在减小。知道如何解决这个问题吗?
Image before Rotation
我正在使用的代码:
UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.image.size.width, self.image.size.height)];
CGAffineTransform t = CGAffineTransformMakeRotation(self.lastContentOffset/5);
rotatedViewBox.transform = t;
CGSize rotatedSize = rotatedViewBox.frame.size;
// Create the bitmap context
UIGraphicsBeginImageContext(rotatedSize);
CGContextRef bitmap = UIGraphicsGetCurrentContext();
// Move the origin to the middle of the image so we will rotate and scale around the center.
CGContextTranslateCTM(bitmap, rotatedSize.width/2, rotatedSize.height/2);
// // Rotate the image context
CGContextRotateCTM(bitmap, 5.0);
// Now, draw the rotated/scaled image into the context
CGContextScaleCTM(bitmap, 1.0, -1.0);
CGContextDrawImage(bitmap, CGRectMake(-self.image.size.width/2 , -self.image.size.height/2 , self.image.size.width, self.image.size.height), \[self.rotatedImage CGImage\]);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.rotatedImage = newImage;
【问题讨论】:
标签: ios objective-c uiimage