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?
Asked
Active
Viewed 180 times
1
-
what is your result? show your output. and what you want it to be. – elk_cloner Jun 15 '17 at 09:11
-
@elk_cloner [this is my demo url](https://github.com/sunwell/Demo/tree/master/CoreAnimationDemo) and [this is the video](https://github.com/sunwell/Demo/blob/master/CoreAnimationDemo/CoreAnimationDemo/test.mp4) – Cr02y Jun 15 '17 at 10:27
1 Answers
2
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];

Yun CHEN
- 6,450
- 3
- 30
- 33
-
Maybe I didn't make the question clear. In my case, the view could be rotate at any angle. And actually, after rotation, the origin of the view is not the left-top corner's coordinate. And [this is my demo url](https://github.com/sunwell/Demo/tree/master/CoreAnimationDemo) and [this is the video](https://github.com/sunwell/Demo/blob/master/CoreAnimationDemo/CoreAnimationDemo/test.mp4) – Cr02y Jun 15 '17 at 10:58
-
-
There are four red point which records the rectangle's four corners' coordinates. What I want to see is that after I rotate or scale the green rectangle, the four red points are still at the corner of the rectangle. So that I can use these four red point to check whether that rectangle is out of a bigger rectangle range (the red line rectangle). – Cr02y Jun 16 '17 at 06:21