方法一:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
//取消 tableSectionHeader 吸顶效果, sectionHeaderHeight为sectionHeader的高度
CGFloat sectionHeaderHeight = FITSCREEN(60);
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);
}
}
方法二:
多写一个cell个数为0的section, 把需要取消吸顶效果的sectionHeader设置为这个section的header
也就是说, 当一个section的numberOfRowsInSection = 0的时候, sectionHeader会自动取消吸顶效果