我想要移除UITableView的分区头部分隔线(或将它们设置为clearColor)。设置tableView.separatorStyle = .none
并不起作用。我也尝试了来自这里的解决方案,但是它们都没有真正对我起作用(也许是因为回答比较旧)。我仍然会在分区头部下面看到这个微小的分隔线。
我在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
}