美文网首页
<iOS 实践经验>修改 tableView 距导航

<iOS 实践经验>修改 tableView 距导航

作者: 貘鸣 | 来源:发表于2017-12-05 11:53 被阅读46次

参考这个链接: StackOverflow.

有时遇到奇葩需求要求设置界面有一些不一样的东西(具体不表), 故手动调整 table View 的各种距离.

要注意的是, 单独调整是没有作用的, 而是需要设置 footer 和 header 的 view, 同时设置其高度:

   func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        if section == 1 {
            return 12.0
        }
        return 0.0
    }

    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.0
    }

    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        return UIView(frame: .zero)
    }

    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return UIView(frame: .zero)
    }

效果如下所示:

image.png

相关文章

网友评论

      本文标题:<iOS 实践经验>修改 tableView 距导航

      本文链接:https://www.haomeiwen.com/subject/ywgqixtx.html