I followed the instructions from this answer here and managed to get my custom UITableView header section like so:
override func viewDidLoad() {
super.viewDidLoad()
let nib = UINib(nibName: "TableSectionHeader", bundle: nil)
billTableView.register(nib, forHeaderFooterViewReuseIdentifier: "TableSectionHeader")
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = billTableView.dequeueReusableHeaderFooterView(withIdentifier: "TableSectionHeader")
let header = cell as! TableSectionHeader
header.lblPerson.text = array[section].name
header.lblTotal.text = "$0.00"
return cell
}
Everything works fine however I need a separator line for the sections and because the section is a UIView from my nib, I'm not able to use the .separatorStyle
...
I need to add a separator line because I want to expand/collapse the rows. Much thanks for your help!