美文网首页OC_UIKit
如何去除UITableView SectionHeader黏性

如何去除UITableView SectionHeader黏性

作者: 忻凯同学 | 来源:发表于2017-06-22 17:26 被阅读17次

当UITableView设置成Plain样式时,如何使sectionHeaderView在tableView滑动时,不停靠在导航条下面:

需遵循 UIScrollViewDelegate

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

          if ((UITableView *)scrollView == self.tableView) {

                    CGFloat sectionHeaderHeight = 32;

                     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);

                     }

          }

}

相关文章

网友评论

    本文标题:如何去除UITableView SectionHeader黏性

    本文链接:https://www.haomeiwen.com/subject/mvbfcxtx.html