

let tableView = UITableView(frame: .zero, style: .plain)
let tableView = UITableView(frame: .zero, style: .grouped)
let tableView = UITableView(frame: .zero, style: .insetGrouped)
private let allSections: [Section] = [
Section(header: "Header1", footer: "footer1", items: [
Item(imageName: "tablecells.fill", title: "Cell1"),
Item(imageName: "tablecells.fill", title: "Cell2"),
Item(imageName: "tablecells.fill", title: "Cell3")
]),
Section(header: "Header2", footer: nil, items: [
Item(imageName: "tablecells.fill", title: "Cell1"),
Item(imageName: "tablecells.fill", title: "Cell2"),
Item(imageName: "tablecells.fill", title: "Cell3")
]),
Section(header: "Header3", footer: "footer3", items: [
Item(imageName: "tablecells.fill", title: "Cell1"),
Item(imageName: "tablecells.fill", title: "Cell2"),
Item(imageName: "tablecells.fill", title: "Cell3")
])
]
//MARK: - 섹션 header 설정
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return allSections[section].header
}
//MARK: - 섹션 header의 높이 설정
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return allSections[section].header == nil ? 0 : 30
}
//MARK: - 섹션 footer 설정
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return allSections[section].footer
}
//MARK: - 섹션 footer의 높이 설정
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return allSections[section].footer == nil ? 0 : 30
}
PlainTableView
https://github.com/zongbeen/AboutiOS/blob/main/AboutiOS/VIew/SubTableViewController/Style/PlainTableViewController.swift
GroupedTableView
https://github.com/zongbeen/AboutiOS/blob/main/AboutiOS/VIew/SubTableViewController/Style/GroupedTableViewController.swift
InsetGroupedTableView https://github.com/zongbeen/AboutiOS/blob/main/AboutiOS/VIew/SubTableViewController/Style/InsetGroupedTableViewController.swift
let tableView = UITableView(frame: .zero, style: .원하는 스타일)