美文网首页
iOS 11 TableView 组间距问题

iOS 11 TableView 组间距问题

作者: 冰霜海胆 | 来源:发表于2017-09-13 17:43 被阅读606次

在 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 组间距问题

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