user924
user924

Reputation: 12145

Margin before first Table View Section

Why do I have margin before first table view section?

Is it not supposed to be only between sections?

enter image description here

Upvotes: 0

Views: 33

Answers (1)

Claudio Castro
Claudio Castro

Reputation: 1569

Overriding

tableView (_tableView: UITableView, heightForHeaderInSection section: Int)

You will get the behavior you want at runtime. If you need to change the values according to the section, you need to do it manually by testing which section you are in.

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
{ 
   if section == 0 {
    return CGFloat.leastNormalMagnitude
   }else{
    return 44
   }
}

Upvotes: 1

Related Questions