How to remove the last border of the last cell in UITableView?

user2289379 picture user2289379 · Aug 28, 2012 · Viewed 50.9k times · Source

In my app, I use a UITableView My problem is that I want to remove the last border of the last cell in UITableView.

Please check the following image:

enter image description here

Answer

Tonny Xu picture Tonny Xu · Nov 12, 2014

The best solution is add a footer view. The following code hide the last cell's line perfectly:

Objective-C

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 1)];

Swift 4.0

tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 1))