如何获取控件相对于屏幕的坐标

一句核心代码搞定:“控件名称 + convertRect: 控件坐标 + toView: 屏幕”

// 获取相对于self.view的坐标
DistributTimeCell *timeCell = [_flowerCheckTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:3]];
    CGRect cellFrame = [timeCell.timerBtn convertRect:timeCell.timerBtn.frame toView:self.view];

// 获取相对于屏幕的坐标
UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
    CGRect rect=[bView convertRect: bView.bounds toView:window];

你可能感兴趣的:(如何获取控件相对于屏幕的坐标)