iOS 11 TableView 组间距问题

在 iOS 11 之前,设置组间距如下:

func tableView(_ tableView: UITableView, heightForHeaderInSection >section: Int) -> CGFloat {
   return 5
}

func tableView(_ tableView: UITableView, heightForFooterInSection >section: Int) -> CGFloat {
   return 5
}

iOS 11 中如果仅仅设置这两项是没有效果的,应该在加上以下设置:

func tableView(_ tableView: UITableView, viewForHeaderInSection >section: Int) -> UIView? {
   return UIView()
}
   
func tableView(_ tableView: UITableView, viewForFooterInSection >section: Int) -> UIView? {
   return UIView()
}

你可能感兴趣的:(iOS 11 TableView 组间距问题)