Vaska Kot Vaska Kot - 5 months ago 41
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)


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