Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get UIView frame position after transform?

I want to get the current position of a UIView after a transform rotate has been applied to it. How can i do that ?

In the UIView doc i found this about the transform property :

"If this property is not the identity transform, the value of the frame property is undefined and therefore should be ignored."

I tried to use center and bounds instead but the result is translated (even when no transform was applied to the rotatedView)

newView.center = rotatedView.center;
newView.bounds = rotatedView.bounds;
newView.transform = rotatedView.transform;

Can anybody help please ?

Thanks in advance, vincent.

like image 946
user142764 Avatar asked Nov 13 '09 13:11

user142764


1 Answers

If you know the frame before transform, you can use CGRectApplyAffineTransform function to calculate it's value after transformation.

like image 130
Nickolay Olshevsky Avatar answered Oct 16 '22 18:10

Nickolay Olshevsky