-(void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat sectionHeaderHeight = 20; 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); } }
在 -(void)scrollViewDidScroll:(UIScrollView *)scrollView方法中添加上诉代码即可
时间: 2024-10-07 05:31:30