Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created June 21, 2016 06:27
Show Gist options
  • Save quangtqag/3f0e887af979bb6beebdbb92b1ef71c2 to your computer and use it in GitHub Desktop.
Save quangtqag/3f0e887af979bb6beebdbb92b1ef71c2 to your computer and use it in GitHub Desktop.
//
// Reference from http://samwize.com/2015/11/06/guide-to-customizing-uitableview-section-header-footer/
//
class TableSectionHeader: UITableViewHeaderFooterView {
@IBOutlet weak var titleLabel: UILabel!
}
let nib = UINib(nibName: "TableSectionHeader", bundle: nil)
tableView.registerNib(nib, forHeaderFooterViewReuseIdentifier: "TableSectionHeader")
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// Dequeue with the reuse identifier
let cell = self.tableView.dequeueReusableHeaderFooterViewWithIdentifier("TableSectionHeader")
let header = cell as! TableSectionHeader
header.titleLabel.text = title
return cell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment