Xcode Check If Point Is in Transformed UIView

256 views Asked by At

I have a UIView with a height of 100 and a width of 50. I am then rotating the view 45 degrees. After I rotate the view, then frame increase. How Can I determine If a point lies inside the view.

If I just compare the frame to the point I will get a false positives when the point is off the view but still in the frame. I want to see if the point is in the initial 50x100 rotated view. enter image description here

Right Now I am getting the height of the point in relation to the view. Then I am using said height to calculate the distance from the left wall; I calculate the length to the side using the fact that is is a 45-45-90 triangle. Using this distance I am checking is the point.x is within the acceptable variance. This method is off as the point moves up and to the right.

Is there a built in function that will give a BOOL or framework. Or what am I doing wrong in my formula.

0

There are 0 answers