Make tableHeaderView frame with constraints.
There is nothing too much to say for this., let’s see the code first.
let headerView = UIView()
let containerView = UIView() // *Need container view for headerView*
containerView.addSubview(headerView)
tableView.tableHeaderView = containerView
..And make some constraints to headerView and containerView whatever you want to.
The point is headerView need container view for itself.