TableView去除sectionheader悬浮效果,设置Group去除顶部留白

来源:互联网 发布:开淘宝的心得体会 编辑:程序博客网 时间:2024/06/11 19:27

我采用的是将tableView设置为UITableViewStyleGrouped,但是设置之后需要对界面进行一系列的调整

如何去除tableView的顶部留白?

分组类型的tableView存在默认数值的header与footer,以下为处理方式:

方法一:

(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{    return 0.1;//return CGFLOAT_MIN;}- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{    return 0.1;//return CGFLOAT_MIN;}

若返回值为0,系统会认为是默认数值而返回默认高度,另外0.1与CGFLOAT_MIN等效.

方法二:

tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, CGFLOAT_MIN)];tableView.tableFooterHeight = 0;



PS:若你需要设置SectionHeader的title,可以将tableHeaderHeight设置为30


参考链接:http://blog.csdn.net/fantasy_jun/article/details/69787408

参考链接:http://blog.sina.com.cn/s/blog_133384b110102wk8b.html


1 0
原创粉丝点击