I am having status bar issues. I have a UIViewController
, this has a container view which embeds a UITabBarController
inside that UIViewController
.
When enabling the status bar in my app using View controller-based status bar appearance
= YES
in my Info.plist
, it acts as normal, the root UIViewController
displays the status bar as you expect.
However, it is causing the UITabBarController
in the container view to push my view contents down by 20 pixels, leaving a gap at the top of my tabbar view for where it thinks the status bar should be.
But of course the status bar isn't shown there because its shown at the top of the screen where it normally is. So it is effectively just adding a gap in my container view.
Turns out the topLayoutGuide
was pushing my view down by 20 pixels for the status bar. Because it was expecting a status bar, the topLayoutGuide
adds this 20 pixel space.
In my storyboard the topmost subview of my view controller had a constraint to fix it to the top of my view. This constraint was the view top
equal to topLayoutGuide bottom
.
This meant that when the topLayoutGuide
added the 20 pixel space, my entire view was offset by that.
By changing the constraint to fix to the topLayoutGuide top
instead, the space created is now just sitting underneath my normal subviews not causing any problems.