您的位置:首页 > 移动开发 > IOS开发

iOS开发笔记--去掉tableview中section的headerview粘性

2016-03-31 09:22 417 查看
ios的tableview中headerview会随着滑动黏在上方,直到新的sectionheaderview出现并替换掉,这是个好的特性,但是在为了实现PM某些需求的时候,又不是很符合心意,在网上查了下,找到了其解决方法:

[objc] view
plain copy







// 去掉UItableview headerview黏性(sticky)

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{

CGFloat sectionHeaderHeight = 40;

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

}

}

利用控制scrollView的滑动来控制headView显示与否。

转自:http://fisher-me.net/?p=495
http://blog.csdn.net/hopedark/article/details/44175695
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: