[将标签与IOS中的表格视图滚动同步

问题描述 投票:0回答:1

我正在开发一个食品配送应用程序,在一个商店中,我有多个菜单类别。我在单个tableview中有项目。因此,当我到达每个部分的标题(例如Breakfast,然后Breakfast选项卡应处于活动状态)时,如何相应地更改选项卡?enter image description here

ios tabs tableview uisegmentedcontrol swift5
1个回答
0
投票

使用这两种方法将标题放在节中。

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
}
© www.soinside.com 2019 - 2024. All rights reserved.