title: How to rotate a CGRect or CGImageCreateWithImageInRect?
body: <p>To describe my project:</p>
  
  <p>I have a rectangle UIImageView frame floating over a white layer. Inside the UIImageView, I'm successfully creating the illusion that it is showing a portion of a background image behind the white layer. You can drag the rectangle around, and it will "redraw" the image so that you can peer into what is behind the white. Its basically this code:</p>
  
  <pre><code>//whenever the frame is moved, updated the CGRect frameRect and run this:
  
  self.newCroppedImage = CGImageCreateWithImageInRect([bgImage.image CGImage], frameRect);
   frame.image = [UIImage imageWithCGImage:self.newCroppedImage];
  </code></pre>
  
  <p>Anyhow, I also have a rotation gesture recognizer that allows the user to rotate the frame (and consequentially rotates the image). This is because the CGRect sent to the CGImageCreateWithImageInRect is still oriented at its original rotation. This breaks the illusion that you're looking through a window because the image you see is rotated when only the frame should appear that way.</p>
  
  <p>So ideally, I need to take the rotation of my frame and apply it to the image created from my bgImage. Does anyone have any clues or ideas on how I could apply this?</p>