iOS开发- tableView取消头部(section hea
2018-07-27 本文已影响1890人
彗星来的那一夜
以下分别是三种方法:
1.可以将tableview的style 由plain改成grouped , iOS11之后 修改sectionHeader的高度需要重写 tableView 的 heightForHeader viewForHeader 方法 ,同理sectionFooter 同样需要重写这两个方法
2.重写一下scrollView的代理方法
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
if(scrollView == self.tableView) {
CGFloat sectionHeaderHeight = 40;
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);
}
}
}
3.sectionHeader 可以做成一个cell(改变一下背景颜色) 这样看起来和section header没什么区别