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
Swift 3
Relative to the tableView
:
let rect = self.tableView.rectForRow(at: indexPath)
Relative to the Screen
:
If you only know the cell
,
if let indexPath = tableView.indexPath(for: cell) {
let rect = self.tableView.rectForRow(at: indexPath)
let rectInScreen = self.tableView.convert(rect, to: tableView.superview)
}
If you know the indexPath
then don't need call the if
statement.