取消uitableview 的footer和header的悬浮

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

CGFloat sectionHeaderHeight = 40;
CGFloat sectionFooterHeight = 10;
CGFloat offsetY = scrollView.contentOffset.y;
if (offsetY >= 0 && offsetY <= sectionHeaderHeight)
{
scrollView.contentInset = UIEdgeInsetsMake(-offsetY, 0, -sectionFooterHeight, 0);
}else if (offsetY >= sectionHeaderHeight && offsetY <= scrollView.contentSize.height – scrollView.frame.size.height – sectionFooterHeight)
{
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, -sectionFooterHeight, 0);
}else if (offsetY >= scrollView.contentSize.height – scrollView.frame.size.height – sectionFooterHeight && offsetY <= scrollView.contentSize.height – scrollView.frame.size.height)
{
scrollView.contentInset = UIEdgeInsetsMake(-offsetY, 0, -(scrollView.contentSize.height – scrollView.frame.size.height – sectionFooterHeight), 0);
}
}

anyShare分享到: