Search code examples
iosuitableviewswiftstatusbar

How to stop an uitableview housed in tabbarcontrol from overlapping the status bar?


My screen looks like this:

enter image description here

You can see the top cell is overlapping the status bar

I have checked a several solutions:

1) Status bar overlaps toolbar

I don't think it is good solution because it requires hardcoding.

2) How to prevent status bar from overlapping content with hidesBarsOnSwipe set on UINavigationController?

The solution is not applicable because I did not use a navigation controller in my app.


Solution

  • Do you use Storyboards and autolauyout?

    If so, just:

    1. Select the ViewController in storyboard

    2. select attribute inspector

    3. Status Bar default

    4. Select The tableView and set the top constraint to top Layout guide

    If its not working this way plan B would be to use a normal ViewController, add a container to it, embed your TableViewController into the container and do the above stuff on the ViewController.