Cr02y
Cr02y

Reputation: 27

How to retrieve all 4 coordinates of a rotated\scaled\translated UIView?

I find a similar question here, and when I translate my view I can solve this problem successfully, but when I rotate or scale my view, I got a incorrect result. Anyone can help me?

Upvotes: 1

Views: 196

Answers (1)

Yun CHEN
Yun CHEN

Reputation: 6648

I found a solution for your demo, and it's been tested. You could use the code from this issue's accepted answer: Find Frame Coordinates After UIView Transform is Applied (CGAffineTransform)

Use the code above as a UIView's Category, and then get the point like:

topleft = [view newTopLeft];
topright = [view newTopRight];
bottomleft = [view newBottomLeft];
bottomright = [view newBottomRight];

The result is:enter image description here

Upvotes: 2

Related Questions