HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 如何删除UITableView节标题分隔符大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想删除(或使它们成为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
    }@H_197_10@

解决方法

不知道为什么要在viewForHeaderInSection方法中返回UITableViewCell,因此可能显示该UITableViewCell的分隔符.尝试从viewForHeaderInSection方法返回单元格的contentView而不是单元格.

func tableView(_ tableView: UITableView,viewForHeaderInSection section: int) -> UIView? {
    let cell = tableView.dequeueReusableCell(withIdentifier: "headerTableViewCell")
    return cell.contentView
}@H_197_10@

大佬总结

以上是大佬教程为你收集整理的ios – 如何删除UITableView节标题分隔符全部内容,希望文章能够帮你解决ios – 如何删除UITableView节标题分隔符所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。