第一个表格视图部分之前的边距

时间:2019-06-16 17:26:54

标签: ios uitableview

为什么在第一个表格视图部分之前有页边空白?

难道不应该只在各节之间吗?

enter image description here

1 个答案:

答案 0 :(得分:1)

覆盖

  
    

tableView(_tableView:UITableView,heightForHeaderInSection部分:Int)

  

您将在运行时获得所需的行为。如果需要根据该部分更改值,则需要通过测试您所在的部分来手动进行。

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
{ 
   if section == 0 {
    return CGFloat.leastNormalMagnitude
   }else{
    return 44
   }
}