我正在开发一个食品配送应用程序,在一个商店中,我有多个菜单类别。我在单个tableview中有项目。因此,当我到达每个部分的标题(例如Breakfast,然后Breakfast选项卡应处于活动状态)时,如何相应地更改选项卡?enter image description here
使用这两种方法将标题放在节中。
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Section \(section)"
}
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let vw = UIView()
vw.backgroundColor = UIColor.red
return vw
}