views:

110

answers:

1

Hello,

I am quite new to iphone development. I have a situation here. I have some labels which can be dragged across the screen.

What I want is when any of these labels are dragged to some textfield and released over a textfiels UIlabel test is assigned to that text field.

The crux in this is I have to check for a condition when UILabel is inside UITextfield.

Can you help me to fabricate this condition.

Thanx in advance

+1  A: 

This might not be the best way, but it should work:

CGRect textfieldFrame = textfield.frame;
CGRect labelFrame = label.frame;
if (!CGRectIsNull(CGRectIntersection(textfieldFrame, labelFrame))) {
   // the two objects' frames are overlapping
}

This only works I believe if the two objects are attached to the same view, but it should get you started.

John Biesnecker
Thank u thanx a lot..........
Ankit Sachan