美文网首页
UITableView解决plain样式header悬停的方案

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

作者: 秦枫桀 | 来源:发表于2018-12-12 14:26 被阅读0次
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悬停的方案

      本文链接:https://www.haomeiwen.com/subject/kaouhqtx.html