Component - Section headers and footers
This UI component shows how to add section headers and footers in a table view on iOS using Swift. Section headers and footers help organize content into groups, making it easier to read and navigate.
This UI component shows how to add section headers and footers in a table view on iOS using Swift. Section headers and footers help organize content into groups, making it easier to read and navigate.
UITableView ├── UITableViewHeaderFooterView (Section Header) ├── UITableViewCell (Row 1) ├── UITableViewCell (Row 2) ├── UITableViewHeaderFooterView (Section Footer) ├── UITableViewHeaderFooterView (Section Header) ├── UITableViewCell (Row 1) ├── UITableViewCell (Row 2) └── UITableViewHeaderFooterView (Section Footer)
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
if section == 0 {
return "End of first section"
} else if section == 1 {
return "End of second section"
}
return nil
}func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section == 0 {
return "First Section"
}
}Pass the test and this pattern moves unknown