Space Between Sections in UITableview

前端 未结 11 2192
醉酒成梦
醉酒成梦 2020-12-08 12:37

I need to reduce the space between two sections ofUITableView. I looked at this question but the solution doesn\'t allow for my custom header view because it c

11条回答
  •  感动是毒
    2020-12-08 13:28

    You need to use method heightForHeaderInSection for defining space between header & cell text. You can also change it depending on different sections for eg. at some sections you may need to show more distance & under some, you don't want to show gap. For such case you can use CGFLOAT_MIN which is 0.000001f. Giving you an example, how you can use different section with different header heights

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        if (section == 0 || section == 2)
        {
            return 55.0;
        }
        else
        {
            return CGFLOAT_MIN;
        }
    }
    

    Hope it will help you.

提交回复
热议问题