UITableView解决plain样式header悬停的方案

if #available(iOS 11.0, *) {
    tableView.contentInsetAdjustmentBehavior = .never
}else {
    automaticallyAdjustsScrollViewInsets = false
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    if scrollView == self.tableView {
        if scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0 {
            scrollView.contentInset = UIEdgeInsets(top: -scrollView.contentOffset.y, left: 0, bottom: 0, right: 0)
        }else if scrollView.contentOffset.y >= sectionHeaderHeight {
            scrollView.contentInset = UIEdgeInsets(top: -(sectionHeaderHeight), left: 0, bottom: 0, right: 0)
        }
    }
}

你可能感兴趣的:(UITableView解决plain样式header悬停的方案)