user1726616 user1726616 - 1 year ago 162
Swift Question

How to change separator line color for single table section?

How to change the separator line color for single table section? I have several sections, but I want to change it only for one of them. In interface builder I can change the color only for all table section separator lines.

case 0:
tableView.separatorColor = UIColor.redColor()
case 1:
and so on...

This one doesn't work for me.

Answer Source

separatorColor is a property of a UITableView. You can't specify a section and you're therefore not specifying a section. So of course the property applies to the whole table view.

The built-in view can't automatically vary colours by section. You'll have to incorporate the separator into your table view cells, or insert separator cells between your existing cells. It's a pain but your options are limited.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download