美文网首页美文共赏
iOS sectionHeaderTopPadding

iOS sectionHeaderTopPadding

作者: 默棉花开 | 来源:发表于2021-11-24 11:46 被阅读0次

    tableView的sectionHeaderTopPadding  是一个iOS15 的一个特性

    它的默认值是 automaticDimension

    参考官网文档:

             iOS 15的一个特性,如果tableview有设置代理

             tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat

             tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat

             就是的titile不为空,默认为给一个值,所以得这是 sectionHeaderTopPadding = 0.0,防止它占位置

    解决方法就是: 

    1: 全局设置

                UITableView.appearance().sectionHeaderTopPadding = 0.0

    2: 某个页面单独设置 

                   tableView.sectionHeaderTopPadding = 0.0

    相关文章

      网友评论

        本文标题:iOS sectionHeaderTopPadding

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