Vaska Kot Vaska Kot - 1 year ago 91
iOS Question

UITableViewCell separator insets don't work

I set separator insets to 0 in my storyboard but when I runs the code, the inset is not 0 . Is it the bug of iOS? Is it any workaround here? (I'm new in iOS development)

Answer Source

Add the willDisplayCell function of UITableViewDelegate to your code and set the separatorInset and layoutMargins of your cell:

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
      cell.separatorInset = UIEdgeInsetsZero
      cell.layoutMargins = UIEdgeInsetsZero
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download