获取按钮在 UIWindow 坐标中的坐标

Get coordinates of button in UIWindow coordinate's

我有 UITableView 一些单元格,在这些单元格中,我有一个按钮。当我点击按钮时,我需要 UIWindow 中中心按钮的坐标。如何做到这一点?

来自 UIView - convertRect:fromView: 文档

view : The view with rect in its coordinate system. If view is nil, this method instead converts from window base coordinates.

试试这一行:

CGRect buttonFrame = [sender.superview convertRect:sender.frame fromView:nil];

这应该让您获得绝对按钮位置。