13

I'm updating my app with Xcode 9 for the iPhone X compatibility. I use auto layout and "Use safe Area Layout Guide" is marked.

I have a header in my UITableView, and, as you can see in the screenshot below, the header view strictly respects the top safe area. The header doesn't follow my tableview top constraint (which is bigger than the safe area)

enter image description here

My tableview constraints :

enter image description here

How can I do to modify my header in order to fill the top of the screen (white area on the screenshot)?

cmii
  • 3,556
  • 8
  • 38
  • 69

3 Answers3

39

In the size inspector of your tableview, set Content Insets to Never

LauraHaworth
  • 391
  • 3
  • 4
8

That's probably due to your constraints are badly set.

You just need to change the top constraint of your Header by double clicking on it.

The screen where you should double click:

The screen where you should double click

And change the Safe Area constraint by the Superview item.

here

Antoine Rucquoy
  • 128
  • 1
  • 10
5

To achieve this set the top area of the table with respect to the superview instead of safearea.

In viewdidload, write this

if #available(iOS 11.0, *) {
    self.tableView.insetsContentViewsToSafeArea = false;
    self.tableView.contentInsetAdjustmentBehavior = .never;
}
Samyak
  • 137
  • 2
  • 9