How to set the full width of separator in UITableView

This worked for me on iOS 8.4 - 9.0 devices using Xcode 6.4 and Swift 1.2:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell = UITableViewCell()


    cell.preservesSuperviewLayoutMargins = false
    cell.separatorInset = UIEdgeInsetsZero
    cell.layoutMargins = UIEdgeInsetsZero

    return cell
}

Swift 5 Update:

cell.preservesSuperviewLayoutMargins = false
cell.separatorInset = UIEdgeInsets.zero
cell.layoutMargins = UIEdgeInsets.zero

In your UITableViewCell

Go to Attributes Inspector in your Interface Builder and simply change "15" to 0. Do this for all the cells you wish to change.

instets

You may need to add [cell setLayoutMargins:UIEdgeInsetsZero]; to your tableViewCell