I have a UITableView
with 1 section and for the section header, I would like to keep everything about the header the same but simply add a button on the right side.
If you want to use Interface Builder to build your section header, you can use a UITableViewCell
as the header. Create a prototype cell for your header in your UITableView, customize as you would any other cell, including adding labels, buttons, and constraints.
You can instantiate in your UITableViewController lazily:
lazy var headerCell: MyHeaderTableViewCell = {
let cell = tableView.dequeueReusableCell(withIdentifier: "Header") as! MyHeaderTableViewCell
return cell
}()
To make it the header:
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return headerCell
}