I want to draw a UIView
in my current CGGraphicsContext
. I draw the UIView
via renderInContext:
, but it's not positioned correctly (always in the top left corner).
I have all values of the UIView
available for drawing the UIView
.
CGRect frame;
CGRect bound;
CGPoint center;
CGAffineTransform transform;
I currently set the position and rotation of the layer like this:
CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
CGContextRotateCTM(context, (CGFloat) atan2(transform.b, transform.a));
But the position is, due to the rotation, not correct and differs from the original position.
How can I restore the original position? The coordinate system hasn't changed in between, it's just an issue to translate the center.x
and center.y
values into something appropriate for CGContextTranslateCTM
.
Edit:
The saved values are correct, saving the correct bounds
, center
and transform
is not the origin of my issue, the origin of my issue, is setting theses values to the drawable CGLayer
via CGContextTranslateCTM
.