Determine coordinates of a UITableViewCell while scrolling

Why not an overlay with a partially transparent gradient PNG in a UIImageView that's less translucent at the top and bottom?

Messing with cell drawing in table scrolling is going to take a big performance hit.


The first step is to use

CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];

which will report the CGRect of a cell within the tableView. However, this value does not change as the tableView scrolls. It is the position relative to the first row of the table (and not the first visible row). To get the position of the cell on the screen you have to convert it to the superviews coordinate system using

CGRect rect = [tableView convertRect:rectInTableView toView:[tableView superview]];

So the following line does it all

CGRect rect = [tableView convertRect:[tableView rectForRowAtIndexPath:indexPath] toView:[tableView superview]];

Swift 4

// Consider the indexPath at row 1, section 0.
let rectWithinTableView : CGRect = self.tableView.rectForRow(at: IndexPath(row: 1, section: 0))
let rectWithSuperViewCoordinates : CGRect = self.convert(rect: rectWithinTableView, to: self.tableView.superview)