简体   繁体   中英

How to Compare the button frame in iPhone?

I am developing an application where I am creating multiple buttons in UIView. Here, user is able to move the button location anywhere in the view, and whenever the button position is changed, I want to compare the moved button location frame with the previous frame. Let me explain briefly, if ( btn1 ) in the position of (100, 100, 30,40) and ( btn2 ) in the position of ( 200,100,30,40) , and when I am dragging my ( btn1 ) to the new position, here I want to get the moved location frame and compare with the ( btn2 ) frame. If it equals then I would like to move ( btn2 ) to (btn1) and (btn1) to (btn2) .

eg:

Btn1(100, 100, 30,40)                 Btn2 ( 200,100,30,40)

使用CGRectEqualToRect(<#CGRect rect1#>, <#CGRect rect2#>)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM