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)
My tableview constraints :
How can I do to modify my header in order to fill the top of the screen (white area on the screenshot)?
To create a basic header or footer with a text label, override the tableView(_:titleForHeaderInSection:) or tableView(_:titleForFooterInSection:) method of your table's data source object. The table view creates a standard header or footer for you and inserts it into the table at the specified location.
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;
}
In the size inspector of your tableview, set Content Insets to Never
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With