星空网 > 软件开发 > 操作系统

去掉tableView的header view的粘黏性

有的项目中,需要使用tableview的headerview,但是想让headerview粘在最顶不,希望和cell一起滚动,可以试试下面的代码来帮你实现这个需求:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {  
    if (scrollView == _tableView) {  
        CGFloat headerViewHeight = 36;
        
        if (scrollView.contentOffset.y <= headerViewHeight && scrollView.contentOffset.y >= 0) {  
            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);  
        } else if (scrollView.contentOffset.y >= headerViewHeight) {  
            scrollView.contentInset = UIEdgeInsetsMake(-headerViewHeight, 0, 0, 0);  
        }  
    }  
}
 
headerViewHeight为项目中headerview的高度



原标题:去掉tableView的header view的粘黏性

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

优化技巧:https://www.goluckyvip.com/tag/3799.html
美国fba海派专线:https://www.goluckyvip.com/tag/37990.html
美国fba海外仓:https://www.goluckyvip.com/tag/37991.html
美国fba海运报价:https://www.goluckyvip.com/tag/37992.html
美国fba海运的费用:https://www.goluckyvip.com/tag/37993.html
美国fba海运的费用是多少:https://www.goluckyvip.com/tag/37994.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
北京丰台区水上乐园哪家好玩?:https://www.vstour.cn/a/366177.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流