当UITableView的style为UITableViewStyleGrouped时,section之间默认的距离往往不是我们想要的。那怎么设置呢?我们知道每个section都有自己的header和footer,它们的高度和就是section之间的间距。知道间距的问题所在就好改了。很简单:
_tableView.sectionHeaderHeight = 10;
_tableView.sectionFooterHeight = 10;
那section之间的距离就是20(10 +10)了;
如果你发现_tableView的顶部还是有间距,不用担心,那是UITableView的header引起的,这样就好了:
_tableView.tableHeaderView = [[UIViewalloc]initWithFrame:CGRectMake(0.0f,0.0f,_tableView.bounds.size.width,0.01f)];