去掉UItableview section headerview黏性

UITabelView在style为plain时,在上拉是section始终粘在最顶上而不是跟随滚动而消失或者出现

可以通过设置UIEdgeInsetsMake:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    if (scrollView == self.myTableView) {

        CGFloat sectionHeaderHeight = 40;(section头部的高度)

        

        if (scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0) {

            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);

        } else if (scrollView.contentOffset.y >= sectionHeaderHeight) {

            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);

        }

    }

}

posted @ 2016-05-19 14:40  有梦想的人,不睡觉  阅读(216)  评论(0编辑  收藏  举报