tableView组头 组尾滑动

元气小坏坏 提交于 2020-03-08 17:27:23

 今天布局tableview 要组头组尾滑动 从网上找的代码 很实用 留下来 每天进步一下

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

    

    if (scrollView == self.detailsTableView)

    {

        UITableView *tableview = (UITableView *)scrollView;

        CGFloat sectionHeaderHeight = 50;

        CGFloat sectionFooterHeight = 60;

        CGFloat offsetY = tableview.contentOffset.y;

        if (offsetY >= 0 && offsetY <= sectionHeaderHeight)

        {

            tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -sectionFooterHeight, 0);

        }else if (offsetY >= sectionHeaderHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight)

        {

            tableview.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, -sectionFooterHeight, 0);

        }else if (offsetY >= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height)         {

            tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -(tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight), 0);

        }

    }

    

 

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!