一:去掉headerView粘性
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.menuTableView)
{
CGFloat sectionHeaderHeight = 25; //sectionHeaderHeight
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);
}
}
}
}
二:去掉footerView粘性
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat sectionHeaderHeight = 30;
if (scrollView.contentOffset.y >= sectionHeaderHeight)
{
scrollView.contentInset = UIEdgeInsetsMake(0, 0, -sectionHeaderHeight, 0);
}
else if (scrollView.contentOffset.y >= sectionHeaderHeight&&(scrollView.contentOffset.y >= scrollView.contentSize.height))
{
scrollView.contentInset = UIEdgeInsetsMake(0, 0, -scrollView.contentOffset.y, 0);
}
}
}