我正在使用UITableViewController
而我正在为我的UITableViewController
播放多个部分,我很好奇我如何获得Apple Music Search等标题,请参阅下面的截图:
我在谈论'最近'和'趋势'标题,那些只是章节标题还是多个表格?
答案 0 :(得分:1)
使用内置的iOS表格视图部分标题。将标题放在集合/数组中,并按如下所示显示:
let titles = ["Section 1", "Section 2", "Section 3"]
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return titles[Int]
}
此外,您需要定义部分数量:
func numberOfSections(in tableView: UITableView) -> Int {
return titles.count
}