How to fix UITableView separator on iOS 7?

Dmitry picture Dmitry · Sep 12, 2013 · Viewed 108.1k times · Source

UITableView draws with ragged lines on iOS 7:

enter image description here

How to fix it? The line between cells should be on the full width of the screen.

Answer

s1m0n picture s1m0n · Sep 12, 2013

UITableView has a property separatorInset. You can use that to set the insets of the table view separators to zero to let them span the full width of the screen.

[tableView setSeparatorInset:UIEdgeInsetsZero];

Note: If your app is also targeting other iOS versions, you should check for the availability of this property before calling it by doing something like this:

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