开发者

assign text of a UIlabel to a text field

开发者 https://www.devze.com 2022-12-14 03:55 出处:网络
I am quite new to iphone development. I have a situation here. I have some labels which can be dragged across the screen.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消