How to change height of grouped UITableView header?

前端 未结 10 690
野性不改
野性不改 2020-12-07 09:22

I know how to change the height of the section headers in the table view. But I am unable to find any solution to change the default spacing before the first section.

10条回答
  •  再見小時候
    2020-12-07 10:23

    you can use viewForHeaderInSection and return a view with any height.

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
    
        int height = 30 //you can change the height 
        if(section==0)
        {
           UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, height)];
    
           return view;
        }
    }
    

提交回复
热议问题