「iOS」开发笔记 (2) : UITableViewStyleGrouped 注意事项

436 阅读1分钟

大家好, 我是杜才.

这篇文章主要是写 UITableView 的一个小知识点, 关键词: UITableViewStyleGrouped, sectionHeader, sectionFooter, tableFooterView.

UITableView styleUITableViewStyleGrouped 时, 布局上会出现的一个小问题, 表现为顶部出现高度为 -35.f 的灰色条. 严格来说这并不是问题.

这个表现是设置 tableView.tableFooterView = someView 引起的, 深层的原因未知. 尝试设置 tableView.tableFooterView = UIView.new, 无效果.

解决方法

  • 如果允许, someView 不作为 tableView.tableFooterView, 和 tableView 同级;
  • 如果不允许, 设置 tableView.contentInset = UIEdgeInsetsMake(-35.f, 0.f, 0.f, 0.f);