UITableViewCell Separator. Hide Separator or Change Left Side Spacing

In this video tutorial I am going to share with you how to change UITableViewCell separator left side spacing or how to hide table cell separator completely using Xcode and how to do it programmatically using Swift.

If you are looking for a way to work with table cell separator programmatically only, below is a quick example. Otherwise, please watch the video.

 Remove UITableViewCell Separator left side space programmatically

  1. Implement cellForRowAtIndexPath function of your UITableViewDataSource
  2. Just before returning the value of UITableViewCell, add the two lines which are marked in bold below
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
let myCell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) 
as! MyCustomTableViewCell


myCell.layoutMargins = UIEdgeInsetsZero
myCell.separatorInset = UIEdgeInsetsZero

return myCell

Hide UITableViewCell Separator

To hide UITableViewCell separator completely, simply set it’s colour to UIColor.clearColor(). This will make the cell separator not visible.

@IBOutlet weak var myTableView: UITableView!
override func viewDidLoad() {
 self.myTableView.separatorColor = UIColor.clearColor()

Watch this video for a complete example and please do subscribe if you are interested in more weekly video tutorials like this.


Below are my other tutorials that have to do with UITableViewCell or UITableView

Swift UITableViewController + custom UITableViewCell

UITableViewController rearrange or reorder table cells example in Swift

UITableViewController delete table cell example in Swift

I hope this very short video tutorial is of some value to you! 🙂

Happy coding!

  • gersen

    Very nice. Thank you

  • Thanks, it was helpful. A few minor changes for Swift 3:

    myCell.layoutMargins = UIEdgeInsets.zero // Changed from UIEdgeInsetsZero
    myCell.separatorInset = UIEdgeInsets.zero


    self.myTableView.separatorColor = UIColor.clear // Changed from UIColor.clearColor()

  • jay soni

    hi bro can you suggest me have a api who’s get a data in table view
    there is two buttons in cell (confirm ) and ( cancel ) when I clicking on confirm button is disabled and I have label ( status ) in the label colour change green same thing in cancel cancel button colour red how to do??
    pls reply fast

  • Got Gravity?

    Thanks – When/if the cell is re-used, how do you turn the separator line back on?