Reputation: 3
I have a tableview that is basically four sections in length, designed for user input. I am not using headers or footers as of now.
Section 0 has 4 rows. Section 1 has 2 rows. Section 2 has 1 row. Section 3 has 1 row.
I want to have section 2 and 3 a little closer together and sections 0 and 1 a little closer together - basically configuring the space in between cells.
I have searched far and wide and have found nothing specific on how to do this. Suggestions?
Thank you in advance,
Upvotes: 0
Views: 4678
Reputation: 109
If your tableview is set to Grouped, and not Plain, you can use the default invisible footers as padding. This way you can leave your headers looking good (and not have a giant gap above the first section)
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 0 || section == 2 {
return 20
} else {
return 40
}
}
Just FYI, if you return 0 it will ignore it and go with the default amount. To completely hide the footer, set it to 0.0001 or something
Upvotes: 2
Reputation: 89242
Handle
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
More info here:
UITableView Not Respecting heightForHeaderInSection/heightForFooterInSection?
Upvotes: 3