1.獲取點(diǎn)擊事件的點(diǎn)相對(duì)于屏幕的位置
如果點(diǎn)擊事件是如下這個(gè)方法(將UIEvent當(dāng)做參數(shù)傳回來(lái))
-(void)expandButtonClicked:(id)sender withEvent:(UIEvent*)event
那么點(diǎn)擊的位置相對(duì)于屏幕的坐標(biāo)就是:
UITouch* touch = [[event touchesForView:btn] anyObject];
CGPoint rootViewLocation = [touch locationInView:[FtAppDelegate shareAppDelegate].rootViewCtrl.view];
2.如果想知道一個(gè)view相對(duì)于屏幕或者另外一個(gè)view 的坐標(biāo)参萄,那么可以通過(guò)如下的方法得到:
UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
CGRect rect=[bView convertRect: bView.bounds toView:window];