assign text of a UIlabel to a text field
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 textfiel开发者_运维问答d 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
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.
精彩评论