让UITableView的headerview不悬停的方法
2016-05-20 13:35
495 查看
当
header在滚动时会默认悬停在界面顶端。取消这一特性的方法有两种:
将
header都会随着scrollview滚动了。不过
2
- (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);
}}
UITableView的
style属性设置为
Plain时,这个tableview的section
header在滚动时会默认悬停在界面顶端。取消这一特性的方法有两种:
将
style设置为
Grouped。这时所有的section
header都会随着scrollview滚动了。不过
grouped和
plain的样式有轻微区别,切换样式后也许需要重新调整UI
2
- (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);
}}
相关文章推荐
- UE4中FName,Fstring,FText使用规则及相互转换
- scala:Guides and Overviews阅读笔记之一 -- Mutable and Immutable Collections
- surface 其实是UEFI与BIOS并存,借用官网的进入方法(少有更改)
- Surface Pro 4 和 Surface Book 使用名为 Surface UEFI(统一可扩展固件接口)的新固件接口
- 【Arduino官方教程第一辑】示例程序 4-11 虚拟调色盘
- android release build error: String index out of range: -125
- Solr源码解析之一 -- 查询解析器QueryParser
- Confluence--BluePrint
- 11.UILable
- Android异步更新UI的四种方式
- Top K Frequent Elements
- easy UI 前端分页
- Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree andsum =
- Arduino入门教程—RFID模块的使用(MF RC522)
- MySQL: Starting MySQL….. ERROR! The server quit without updating PID file解决办法
- uisearchbar背景色
- WCF学习系列三--【WCF Interview Questions – Part 3 翻译系列】
- UITableViewCell 自适应高度
- topic 和queue的区别和应用 activeMQ
- UE 的文件比较方法