美文共赏

iOS sectionHeaderTopPadding

2021-11-24  本文已影响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

上一篇下一篇

猜你喜欢

热点阅读