博客> UItableview headerview黏性(sticky)
UItableview headerview黏性(sticky)
2017-09-22 11:03 评论:0 阅读:234 yutaotst
ios UITableView headView 去除粘性

UItableview headerview黏性(sticky)

//去掉UItableview headerview黏性(sticky)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.tableView)
    {
        CGFloat sectionHeaderHeight = 97; //这里headView的高度是多少就是多少
        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);
        }

    }
}
收藏
1
sina weixin mail 回到顶部