去掉UITableView HeaderView或FooterView随tableView 移动的黏性(sticky)

控制器中实现以下方法即可:

 1 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
 2 
 3     CGFloat sectionHeaderHeight = 40;
 4 
 5     if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
 6 
 7         scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
 8 
 9     } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
10 
11         scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
12 
13     }
14 
15 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2021-11-27
  • 2021-09-23
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-04-18
  • 2021-07-22
相关资源
相似解决方案