Space Between Sections in UITableview

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.

tableview screenshot


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
}