The geometry of the graphics context can be adjusted to the UIView
s geometry with this snippet:
// Center the context around the view's anchor point
CGContextTranslateCTM(context, [view center].x, [view center].y);
// Apply the view's transform about the anchor point
CGContextConcatCTM(context, [view transform]);
// Offset by the portion of the bounds left of and above the anchor point
CGContextTranslateCTM(context,
-[view bounds].size.width * [[view layer] anchorPoint].x,
-[view bounds].size.height * [[view layer] anchorPoint].y);