I have a UIButton and a UIView that belong to two different views hierarchies and I'm trying to detect a collision when I drag my button to the “viewTrashArea”.
The problem is that the frame of the button and the frame of the view are in different coordinates and therefore make the collision think that they are touching but they are far away from each others.
How can I detect the collision based on the global screen position?
Given
UIButton *button;
UIView *viewTrashArea;
This line would return true if they intersect:
CGRectIntersectsRect([button convertRect:button.bounds toView:viewTrashArea], viewTrashArea.bounds);