How to change height of grouped UITableView header?

前端 未结 10 691
野性不改
野性不改 2020-12-07 09:22

I know how to change the height of the section headers in the table view. But I am unable to find any solution to change the default spacing before the first section.

10条回答
  •  庸人自扰
    2020-12-07 10:00

    This worked for me with Swift 4. Modify your UITableView e.g. in viewDidLoad:

    // Remove space between sections.
    tableView.sectionHeaderHeight = 0
    tableView.sectionFooterHeight = 0
    
    // Remove space at top and bottom of tableView.
    tableView.tableHeaderView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: CGFloat.leastNormalMagnitude)))
    tableView.tableFooterView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: CGFloat.leastNormalMagnitude)))
    

提交回复
热议问题