iOS开发之设置tableview的区头随着tableview滑动而滑动,使它不会粘在头部

来源:互联网 发布:教学软件大全 编辑:程序博客网 时间:2024/05/13 12:39

实际开发中我们可能会遇到各种各样的问题:比如说有对tableView的区头随着tableView的滑动而滑动的需要时,我们可以这样做


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

    CGFloat sectionHeaderHeight = 50;
    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 1
原创粉丝点击