To change header/footer space the following methods have to be implemented:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
AND
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
(use corresponding methods to change footer height)
The following code completely removes spaces around sections:
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return .leastNonzeroMagnitude
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return .leastNonzeroMagnitude
}
0.0. But it was showing a gray area with a (default) 30point height. Using0.0is unaccepted. you must use any value above0.0e.g.0.0001. - Honey0.0does not work. I have a more thorough answer for the same issue here: stackoverflow.com/a/22185534/2789144 - James Nelson