Getting the exact location of a UITableViewCell

后端 未结 9 588
滥情空心
滥情空心 2021-01-30 20:10

Given a UITableView, how can I find the location of a specific UITableViewCell? In other words, I want to get its frame relative to my iPhone screen, n

9条回答
  •  -上瘾入骨i
    2021-01-30 20:42

    Swift-version of Tomasz and Jhaliya's answers in case anyone (else) struggles with this:

    var cellRect = tableView.rectForRow(at: indexPath)
    cellRect = cellRect.offsetBy(dx: -tableView.contentOffset.x, dy: -tableView.contentOffset.y)
    

提交回复
热议问题