Ich rotiere ein UIImage Nach einem Maßstab Wert.Meine Skalierung und Rotation funktionieren gut, aber das Problem ist nach dem Drehen uiimage, die Bildgröße (Breite & Höhe) abnimmt . Irgendeine Idee, wie man das Problem löst?
Image before RotationUIImage Größe (Breite und Höhe) ist abnehmend nach der Drehung
Der Code ich verwende:
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;
Danke Kumpel, ich habe die Kontextgröße geändert, es funktionierte @ s0urcer –