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 combines the space of the footer and header.
Here is a picture of the UITableView
. The black color is the UITableView
background color.
The way I achieve adding spacing between cells is to make numberOfSections = "Your array count" and make each section contains only one row. And then define headerView and its height. This works great.
Short answer is that this extra padding is probably due to the table view header (not the section header), and that UITableView doesn't like to be assigned a header with a height of 0.0.
You can remove this by setting a property on the table view: self. tableView.
Did you try override this function:
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return .leastNormalMagnitude }
On iOS 15 you may want to reduce the sectionHeaderTopPadding
if #available(iOS 15.0, *) { tableView.sectionHeaderTopPadding = 0 }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With