Reputation: 3655
I've create a uitableview with two sections. However there seems to be some unwanted space between the second section header and the last cell in the first section (see screenshot). Does anybody know how to remove it?
Code per request:
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerCell = tableView.dequeueReusableCellWithIdentifier("SectionHeader") as MyRentalsScetionsHeaders
switch(section){
case 0:
headerCell.sectionName.text = "Upcoming"
headerCell.backgroundColor = UIColor(red: 87/255.0, green: 189/255.0, blue: 135/255.0, alpha: 1)
default:
headerCell.sectionName.text = "Ended"
headerCell.backgroundColor = UIColor(red: 203/255.0, green: 205/255.0, blue: 200/255.0, alpha: 1)
}
return headerCell
}
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
switch(section){
case 0:
return 45.0
default:
return 30.0
}
}
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.00001
}
func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView(frame: CGRectZero)
}
My current solution is setting the height for the footer to 0.00001, which is allowed. It's not really the most ideal solution, but it looks a lot better :) if anybody know a pixel-perfect solution, I'd love that!
Upvotes: 2
Views: 6846
Reputation: 4325
Select TableView > Open Size Inspector > Set SectionHeight of Header to 0.
Upvotes: 3
Reputation: 8108
Select tableview and in attribute inspector. There is option to set space between header and footer. 22 is default.
Upvotes: 2