大家好, 我是杜才.
这篇文章主要是写 UITableView 的一个小知识点, 关键词: UITableViewStyleGrouped, sectionHeader, sectionFooter, tableFooterView.
当 UITableView style 为 UITableViewStyleGrouped 时, 布局上会出现的一个小问题, 表现为顶部出现高度为 -35.f 的灰色条. 严格来说这并不是问题.
这个表现是设置 tableView.tableFooterView = someView 引起的, 深层的原因未知. 尝试设置 tableView.tableFooterView = UIView.new, 无效果.
解决方法
- 如果允许,
someView不作为tableView.tableFooterView, 和tableView同级; - 如果不允许, 设置
tableView.contentInset = UIEdgeInsetsMake(-35.f, 0.f, 0.f, 0.f);