UITableViewStyleGroup设置头部高度的方法

  1. 设置标头的高度为特小值(不能为0,为0的话苹果会取默认值就无法消除头部间距了)
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0.001)];
view.backgroundColor = [UIColor redColor];
self.tableView.tableHeaderView = view;
  1. 写代理方法(中间的留白其实是段尾的高度,代理的作用是设置段尾的高度,返回值也不能为 0)
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.01f;
}

你可能感兴趣的:(UITableViewStyleGroup设置头部高度的方法)