去掉UItableview headerview黏性
2016-07-08 13:41
387 查看
有时候使用UITableView所实现的列表,会使用到section,但是又不希望它粘在最顶上而是跟随滚动而消失或者出现,下面的代码片段就是实现此功能:
sectionHeaderHeight 的值要根据自己的而定
_tableView 如果一个类里有多个表格,要明确指明要去掉哪一个表格头的粘性
1 2 3 4 5 6 7 8 9 10 11 12 13 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView == _tableView) { CGFloat sectionHeaderHeight = 36; 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 的值要根据自己的而定_tableView 如果一个类里有多个表格,要明确指明要去掉哪一个表格头的粘性
相关文章推荐
- 【打CF,学算法——四星级】CodeForces 689D Friends and Subsequences (RMQ+二分)
- (原创软件)CnCrypt 密码生成工具,提取自CnCrypt的一个独立版本
- BlockingQueue
- 【WWDC2016 Session笔记】 iOS 10 UICollectionView新特性
- Codeforces 689D Friends and Subsequences(二分+RMQ)
- 根据Request获取客户端IP 内网IP及外网IP
- javax.naming.NameNotFoundException: QueueConnectionFactory not bound
- 【UOJ 209】【UER #6】票数统计
- 找不到符号: 变量 BuildConfig
- UITextField文本字段控件的位置
- WRONGTYPE Operation against a key holding the wrong kind of value
- UITextField占位文字颜色-attributedPlaceholder
- Java并发编程与技术内幕:ArrayBlockingQueue、LinkedBlockingQueue及SynchronousQueue源码解析
- Process 'command '/Users/wcc/Android/sdk/build-tools/23.0.0/aidl'' finished with non-zero exit valu
- CUICatalog: Invalid asset name supplied:
- Android Bluetooth Low Energy官方文档翻译
- abap 弹出对话框函数POPUP_GET_VALUES的使用方法
- 如何监控项目里所有UI线程的操作(实战,BlockCanary)?
- UITextView的placehoder背景文字实现带并限制文字字数
- UICollectionReusableView 使用时的一些问题