iOS 获取控件相对屏幕(父N级)坐标位置

需要获取坐标的对象为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];

该方法可以获取任意线性点层级视图绝对坐标,层级不深时非常好用。

原文地址:https://www.cnblogs.com/abasolution/p/6550849.html