需要獲取坐標的對象為label,則該視圖相對屏幕的位置,可使用下面方法實現:
NSInteger index = _index + 100;
UILabel *label = [[self.view viewWithTag:_selectCellIndex] viewWithTag:index];
UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
CGRect rect=[label convertRect: label.bounds toView:window];
該方法可以獲取任意線性點層級視圖絕對坐標,層級不深時非常好用。