Created
June 21, 2016 06:27
-
-
Save quangtqag/3f0e887af979bb6beebdbb92b1ef71c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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