Make UITableView ignore Safe Area

9k Views Asked by At

I have a TableView inside a ViewController. I made the TableView stretch to the View SuperMargings (with constraints) and disabled all SafeArea Inset options but my TableView is still under the SafeArea when I run my project.

How can I make my TableView go full height on iPhones with notch?

2

There are 2 best solutions below

0
On BEST ANSWER

If you have already pinned tableView to it's superview(not to safeArea) with constraints but tableView still respects safeArea there is property contentInsetAdjustmentBehavior in UIScrollView(UITableView is subclass of UIScrollView as we know) since iOS 11.

This property is UIScrollView.ContentInsetAdjustmentBehavior enum with 4 options. You need to set .never to contentInsetAdjustmentBehavior.

1
On

What works with any view is to associate the bottom constraint of the table view to the bottom anchor of the root (or parent) view (instead of the SafeArea).

This can be done in the storyboard editor double clicking on the constraint in the right inspector and changing the first item anchor from SafeArea to Superview (or any wanted view).

You can then set the edge insets at will if needed (to avoid content remain partially hidden behind the rounded frame corners or the notch if applying the same procedure to the top anchor)

enter image description here