【发布时间】:2017-07-06 21:09:19
【问题描述】:
我想删除(或将它们设为 clearColor)UITableView 的部分标题分隔符。设置tableView.separatorStyle = .none 不起作用。我也尝试过here 的解决方案,但它们都没有真正为我工作(可能是因为答案很老了)。我仍然在部分标题下方看到这个小分隔符。
我在 Storyboard 中创建了 UITableView 并在那里添加了一个 UITableViewCell。然后我将它设置为这样的标题:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: "headerTableViewCell")
return cell
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 1 {
return 49
}
return 0
}
【问题讨论】:
-
为什么要在 viewForHeaderInSection 中添加单元格?
标签: ios swift uitableview storyboard