美文网首页
TableView头视图不悬停方法

TableView头视图不悬停方法

作者: 西门丨不吹雪 | 来源:发表于2016-10-26 18:03 被阅读109次

第一种方法:在func scrollViewDidScroll(_ scrollView: UIScrollView)方法中写

override 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)
        }
    }
}

第二种方法:将tableview的plain改为group

相关文章

网友评论

      本文标题:TableView头视图不悬停方法

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