如果去掉UITableView上的section的headerView和footerView的悬浮效果

项目需要cell的间距,又不需要悬浮效果,百度之后找到这个方法,记录一下,备忘。

用UIScrollView的代理方法实现

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat sectionHeaderHeight = 10; //这里是我的headerView和footerView的高度
    if (_tableView.contentOffset.y<=sectionHeaderHeight&&_tableView.contentOffset.y>=0) {
        _tableView.contentInset = UIEdgeInsetsMake(-_tableView.contentOffset.y, 0, 0, 0);
    } else if (_tableView.contentOffset.y>=sectionHeaderHeight) {
        _tableView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}


原文地址:https://www.cnblogs.com/wanghang/p/6298885.html