PRAVEEN K.P
PRAVEEN K.P

Reputation: 101

how to find if a view touches another view's frame while dragging?

I have a some movable views in the user interface and I need to know if the moving view's frame touched any of the other view's frame and if touched I need to merge these two views into a single view.

i have added a sample image down here enter image description here

Upvotes: 0

Views: 112

Answers (1)

Anil Varghese
Anil Varghese

Reputation: 42977

You can useCGRectIntersectsRect method. Get the bounds of two views and use this method

rect1 = self.view1.bounds;
rect2 = self.view2.bounds;

CGRectIntersectsRect(CGRect rect1, CGRect rect2)

Upvotes: 1

Related Questions