I know how to change the height of the section headers in the table view. But I am unable to find any solution to change the default spacing before the first section.
In Swift 4
Remove extra top padding in grouped tableview.
Here height is given 1 as minimal height for the section header because you cannot give 0 as tableview will take it default top margin if assigned zero height.
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 1
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}