Search code examples
swiftuitableviewtableview

Hiding header of UITableView


I have TableView with invisible header. I already tried unsuccessfully to hide the header with:

tableView.tableHeaderView = .init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))

tableView.tableHeaderView?.removeFromSuperview()

tableView.tableHeaderView = nil

But I found out that if you call a multitask or manually change the theme to dark/light, this header disappears

Here is an example

So, is this a bug, or I missing something?


Solution

  • This code works perfectly

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