UITableView Header 不懸停的tips之一
也可以關注我的個人博客
利用contentInset
向上偏移去阻斷系統懸停的計算位置,我們可以設置tableHeaderView
的高度與sectionHeaderHeight
高度一致
let headerView = UIView(frame: CGRect(x: 0, y: 0, width: 375, height: 10.0))
tableView.tableHeaderView = headerView
tableView.contentInset.top = -10.0
//設置sectionHeaderHeight
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 10
}