Member-only story
Separator line in UITableView iOS
Editing the width of Separator Lines
You can set make your table view’s separator lines extend the to various widths across the table by changing the layoutMargins: property on your cell(s). This can be achieved in a number of ways.
Changing the Separator Lines for specific cells
In either your table view data source’s cellForRowAtIndexPath: method or the willDisplayCell: method, set the cell’s layoutMargins: property to UIEdgeInsetsZero (extends to full width of the table), or to whatever you may desire here.
Objective-C
[cell setLayoutMargins:UIEdgeInsetsZero];// May also use separatorInset[cell setSeparatorInset:UIEdgeInsetsZero];
Swift
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {cell.separatorInset = UIEdgeInsetsZerocell.layoutMargins = UIEdgeInsetsZero
}func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{cell.separatorInset = UIEdgeInsetsZerocell.layoutMargins = UIEdgeInsetsZero
}
Remove all Separator Lines-
The thin gray lines between each cell may not be exactly the look you’re going for. It’s fairly straightforward to hide them from view.