美文网首页iOS视频开发
改变tableview section headerView 的

改变tableview section headerView 的

作者: 大老虎_Robin | 来源:发表于2017-06-07 17:53 被阅读14次
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {// any offset changes
    
    // change the position of section header when scrolled by changing scroll's contentInset
    CGFloat sectionHeaderHeight = 0;
    
    CGFloat ceilPositon = CGRectGetHeight(self.headerView.frame) - sectionHeaderHeight;

    if (scrollView.contentOffset.y < sectionHeaderHeight){
        scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    }
    // the "scrollView.contentOffset.y" must larger than its position to ceiling
    if (scrollView.contentOffset.y >= ceilPositon && scrollView.contentOffset.y >= sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(sectionHeaderHeight, 0, 0, 0);
    }
}

相关文章

网友评论

    本文标题:改变tableview section headerView 的

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