Vaska Kot
Vaska Kot

Reputation: 13

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)

Upvotes: 0

Views: 100

Answers (1)

d.felber
d.felber

Reputation: 5418

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
}

Upvotes: 3

Related Questions