Since I discovered AutoLayout I use it everywhere, now I\'m trying to use it with a tableHeaderView.
I made a subclass of
The following worked for me.
UIView as the header view.UIViewThe main benefit I see is limiting frame calculations. Apple should really update UITableView's API to make this easier.
Example using SnapKit:
let layoutView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.width, height: 60))
layoutView.backgroundColor = tableView.backgroundColor
tableView.tableHeaderView = layoutView
let label = UILabel()
layoutView.addSubview(label)
label.text = "I'm the view you really care about"
label.snp_makeConstraints { make in
make.edges.equalTo(EdgeInsets(top: 10, left: 15, bottom: -5, right: -15))
}