Is there a way to remove the separator line from a UITableView?

Tricky picture Tricky · May 29, 2009 · Viewed 124.1k times · Source

I'm looking for a way to completely remove the separator line in a UITableView when in the plain mode. This is done automatically in grouped, but this also changes the dimensions of the table in a way that is hard to measure. I have set the seperator line color to colorClear. But this does not completely solve the problem.

As I am trying to draw a custom background view in the cells, and I want the cells to be seamless, the one pixel line that remains in-between is causing me problems. Is there a more elegant workaround then using a grouped view and then stretching it?

Answer

Bart Jacobs picture Bart Jacobs · May 29, 2009

You can do this with the UITableView property separatorStyle. Make sure the property is set to UITableViewCellSeparatorStyleNone and you're set.

Objective-C

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

In Swift (prior to 3)

tableView.separatorStyle = .None

In Swift 3/4/5

tableView.separatorStyle = .none