title: Can i move the origin when doing a rotation transform in Quartz 2D for the iPhone?
body: <p>Sorry if this is obvious or covered elsewhere, but i've been googling all day and haven't found a solution that actually worked.</p>
  
  <p>My problem is as follows: I am currently drawing an image in a full screen UIView, for examples sake we'll say the image is in the bottom right corner of the UIView. I'd like to do a rotation transform(CGAffineTransformMakeRotation) at the center of that image, however, by default the rotation command rotates around the center of the UIView it self. As a result, my image moves around the screen when i rotate instead of it staying in place and rotating around its own center.</p>
  
  <p>From what i've gathered, i need to translate my context so that the origin(center of the UIView) is at the center of my image, Rotate, and then restore the context by translating back to the original spot.</p>
  
  <p>The following is the closest thing i've gotten to work, but the problem is that while the image is rotating, it moves downward while it's rotating. I think this is caused by animation tweening the 1st step translate and 3rd step translate instead of just realizing that the beginning and end point on the translates would be the same...</p>
  
  <pre><code>// Before this i'd make a call to a function that draws a path to a passed in context
  CGAffineTransform inverseTranslation = CGAffineTransformMakeTranslation( transX, transY );
  CGAffineTransform translation = CGAffineTransformMakeTranslation( -transX, -transY );
  CGAffineTransform rot = CGAffineTransformMakeRotation( 3.14 );
  CGAffineTransform final = CGAffineTransformConcat( CGAffineTransformConcat( inverseTranslation, rot ), translation );
  // Then i apply the transformation animation like normal using self.transform = final etc etc
  </code></pre>
  
  <p>I've also tried stuff like CGContextTranslateCTM and    CGContextSaveGState/UIGraphicsPushContext, but these seem to have little effect.</p>
  
  <p>I've been fighting with this for days and my current solution seems close, but i have no clue how to get rid of that translating tweening. Does anyone have a solution for this or a better way to go about this?</p>
  
  <p>[update]
  For the time being i'm drawing my image centered at the UIview's center and then setting the UIView.center property to the origin i'd like to rotate and then doing the rotate command. Seems like a bit of a hack, but until i can get the real translates working it's my only choice.
  Thanks!</p>