title: Rotating a UIImageView by angles
body: <p>I want to rotate a UIImageView with the press of a button. I am using this code:</p>
  
  <pre><code>#import "UIImage-Extensions.h"
  UIImage *rotatedImage = [SplashItGroupPicker.image imageRotatedByDegrees:360/arrayCount];
  SplashItGroupPicker.image = rotatedImage;
  </code></pre>
  
  <p>and in "UIImage-Extensions.h" i have:</p>
  
  <pre><code>@interface UIImage (CS_Extensions)
  - (UIImage *)imageRotatedByRadians:(CGFloat)radians;
  - (UIImage *)imageRotatedByDegrees:(CGFloat)degrees;
  </code></pre>
  
  <p>and in the .m:</p>
  
  <pre><code>- (UIImage *)imageRotatedByRadians:(CGFloat)radians
  {
  return [self imageRotatedByDegrees:RadiansToDegrees(radians)];
  }
  
   - (UIImage *)imageRotatedByDegrees:(CGFloat)degrees
  {
  // calculate the size of the rotated view's containing box for our drawing space
  UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.size.width,     self.size.height)];
  CGAffineTransform t = CGAffineTransformMakeRotation(DegreesToRadians(degrees));
  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, DegreesToRadians(degrees));
  
  // Now, draw the rotated/scaled image into the context
  CGContextScaleCTM(bitmap, 1.0, -1.0);
  CGContextDrawImage(bitmap, CGRectMake(-self.size.width / 2, -self.size.height / 2, self.size.width, self.size.height), [self CGImage]);
  
  UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  return newImage;
  
  }
  </code></pre>
  
  <p>...the rotation works fine, but when the image is rotated, the image also gets smaller and I can't understand why. Any ideas?</p>