美文网首页iOS技术
UITableView去除SectionHeader悬浮,跟随滑

UITableView去除SectionHeader悬浮,跟随滑

作者: FengxinLi | 来源:发表于2016-02-23 11:39 被阅读5589次

http://www.jianshu.com/p/3c52a48d4aeb。这个是原文

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

{

CGFloat sectionHeaderHeight;

sectionHeaderHeight = 20;

if (scrollView == _tableView) {

//去掉UItableview的section的headerview黏性

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

}

}

}

sectionHeaderHeight 这个值经过测试都可以的。不知道到底是以那个为准。弄明白了在来

2第二种方法就是可以把UITableview的风格变成Group,就会跟随滑动了

相关文章

网友评论

    本文标题:UITableView去除SectionHeader悬浮,跟随滑

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