美文网首页
Swift4.0之tableview的section不悬停的方法

Swift4.0之tableview的section不悬停的方法

作者: Miu七七 | 来源:发表于2017-10-11 16:43 被阅读42次
总是有那么几个产品经理需求奇葩,ios的tableview中headerview会随着滑动悬停在上方,直到新的sectionheaderview出现并替换掉,这是个好的特性··············

写在tableview代理方法中就好

 func scrollViewDidScroll(_ scrollView: UIScrollView) {
    let  sectionHeaderHeight: CGFloat  = “sectionheader的高度”
      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)
         }
       
    }
    


相关文章

网友评论

      本文标题:Swift4.0之tableview的section不悬停的方法

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