-1

How do you remove the space above a grouped UITableView?

enter image description here

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Nagra
  • 1,529
  • 3
  • 15
  • 25
  • Here is the solution https://stackoverflow.com/questions/9932711/how-to-remove-the-blank-space-at-the-top-of-a-grouped-uitableview/22185534 – pw2 Oct 23 '19 at 12:36

2 Answers2

0

You can remove the space by adding a UIView to the table view .tableHeaderView property i.e.

tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))

CGFloat.leastNonzeroMagnitude gives you the least positive number i.e. less than or equal to all positive numbers, but greater than zero.

Nagra
  • 1,529
  • 3
  • 15
  • 25
0

Use this delegate method to set height of header section to minimum:

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 0.1
}
Mumtaz Hussain
  • 925
  • 9
  • 23