美文网首页
去掉TableView的section header和foote

去掉TableView的section header和foote

作者: 番茄大叔 | 来源:发表于2016-12-02 16:57 被阅读0次

转载自:http://www.cnblogs.com/iCocos/p/4949375.html


只去掉header的

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

if (scrollView == self.tableView)

{

CGFloat sectionHeaderHeight = 64; //你的header高度

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);

}

}


header 和 footer 的

UITableView *tableview = (UITableView *)scrollView;

CGFloat sectionHeaderHeight = 64;//头

CGFloat sectionFooterHeight = 120;//脚

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);

}

}

}


如有问题欢迎反馈!

相关文章

网友评论

      本文标题:去掉TableView的section header和foote

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