Change tableView separator insets

Swift 3:

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    if (cell.responds(to: #selector(setter: UITableViewCell.separatorInset))) {
        cell.separatorInset = UIEdgeInsets.zero
    }

    if (cell.responds(to: #selector(setter: UIView.preservesSuperviewLayoutMargins))) {
        cell.preservesSuperviewLayoutMargins = false
    }

    if (cell.responds(to: #selector(setter: UIView.layoutMargins))) {
        cell.layoutMargins = UIEdgeInsets.zero
    }
}

For conversion of the answer (Separator lines for UITableViewCellStyleSubtitle cells not taking the full width) in Swift

enter image description here

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell = tableView.dequeueReusableCellWithIdentifier("yourcell") as! UITableViewCell

    if (cell.respondsToSelector("setPreservesSuperviewLayoutMargins:")){
        cell.layoutMargins = UIEdgeInsetsZero
        cell.preservesSuperviewLayoutMargins = false
    }
}

By Checking version number :

let floatVersion = (UIDevice.currentDevice().systemVersion as NSString).floatValue

if (floatVersion > 8.0){
    cell.layoutMargins = UIEdgeInsetsZero
    cell.preservesSuperviewLayoutMargins = false
}

This is old version and it doesn't work anymore.

cell.layoutMargins = UIEdgeInsetsZero
cell.preservesSuperviewLayoutMargins = false

You can use this (for swift, in Objective C you can call the same thing)

cell.separatorInset = UIEdgeInsets.zero