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

2017-12-05  本文已影响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
上一篇 下一篇

猜你喜欢

热点阅读