fra*_*gon 6 storyboard uitableview ios swift
我想删除(或使它们成为clearColor)UITableView的节头分隔符.设置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
}
Run Code Online (Sandbox Code Playgroud)
Nir*_*v D 10
不知道为什么你正在返回UITableViewCell的viewForHeaderInSection方法等都可能是它有可能是显示的是隔膜UITableViewCell.尝试contentView从viewForHeaderInSection方法返回单元格而不是单元格.
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: "headerTableViewCell")
return cell.contentView
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7684 次 |
| 最近记录: |