核心代碼 ...
核心代碼
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight = sectionHead.height; // 區頭高度 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); } }