TableView的FooterView和HeaderView
1.停留在顶部和底部的样式:UITableViewStylePlain。
2.不停留在顶部和底部的样式:UITableViewStyleGrouped。
3.停留在顶部和不停留底部的样式:UITableViewStylePlain。如下:
重写 - (void)scrollViewDidScroll:(UIScrollView *)scrollView;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//去掉底部视图
CGFloat sectionFooterHeight = 42;
scrollView.contentInset = UIEdgeInsetsMake(0, 0, - sectionFooterHeight,0);
}
4.不停留在顶部和底部的样式:UITableViewStylePlain。如下:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//去掉底部视图
CGFloat sectionFooterHeight = 42;
scrollView.contentInset = UIEdgeInsetsMake(0, 0, - sectionFooterHeight,0);
//去掉头部视图
CGFloat sectionFooterHeight = 30;
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);
}
}