I have a UIView
and I apply to it a CGAffineTransform
. I would like to be able to know the frame of the view if the transform had not be applied.
I am looking for a (simple) solution that handles the case where the transform is the "zero-transform" (which is not invertible).
The following does not work for the "zero-transform", I guess.
CGRect result ;
CGAffineTransform transform = self.transform ;
result = CGRectApplyAffineTransform(self.frame, CGAffineTransformInvert(transform)) ;
return result ;
I need to do this for an animation:
transform
"to 0". The view is inserted but the frames of all the elements do as if the view was not here.transform
"to 1".My transform is a scale transform.
transform
does not affect center
nor bounds
.
So, you can calculate it by this simple code:
CGPoint center = view.center;
CGSize size = view.bounds.size;
CGRect frameForTransformIdentity = CGRectMake(
center.x - size.width / 2,
center.y - size.height / 2,
size.width,
size.height
);