Is there a way to make UITableView cells in iOS 7 not have a line break in the separator?

Anthony Glyadchenko picture Anthony Glyadchenko · Aug 21, 2013 · Viewed 36.1k times · Source

I noticed that in iOS 7, UITableViewCells have a line break in the separator of the cell that iOS 6 does not have. Is there a way to get rid of this line break? Changing the separator to none and then making UIViews with the color of the separator still causes the white separator to occur regardless.

Answer

Luis E. Prado picture Luis E. Prado · Sep 11, 2013

For iOS7:

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [self.tableView setSeparatorInset:UIEdgeInsetsZero];
}

For iOS8:

First configure your table view as follows:

if ([self.tableView respondsToSelector:@selector(layoutMargins)]) {
    self.tableView.layoutMargins = UIEdgeInsetsZero;
}

Then in your cellForRowAtIndexPath: method, configure the cell as follows:

if ([cell respondsToSelector:@selector(layoutMargins)]) {
    cell.layoutMargins = UIEdgeInsetsZero;
}

Note: Include both layoutMargins and separatorInset, to support both iOS versions