如何检索旋转\缩放\翻译的UIView的所有4个坐标?

时间:2017-06-15 09:03:13

标签: ios objective-c transform

我发现了一个类似的问题here,当我翻译我的视图时,我可以成功解决这个问题,但是当我旋转或缩放视图时,我的结果不正确。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分: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];

The result is:enter image description here