Reputation: 71
I have an app almost entirely built with Xcode Interface Builder and no code with the exception of the overrides of supportedInterfaceOrientations
to fix the UIViewControllers
orientation to either portrait or landscape. The app is composed of two view controllers:
UINavigationController
and has a navigation bar. This view controller's orientation is portrait-fixed.When the button in the second view controller is pressed, the VC slides out of the window and once the animation is over the status bar appears over the navigation bar, partially overlapping it (NOTE: the layout fixes itself when the status is pressed). You can view the problem in the following video: https://imgur.com/FIBoszM
The following screenshots shows the "actual" (left) and "expected" (right) behaviours.
Why is this happening?
Upvotes: 3
Views: 167
Reputation: 4445
There are two possible solutions depending on your preferences.
<key>UIViewControllerBasedStatusBarAppearance</key> <false/> <key>UIStatusBarHidden</key> <true/>
self.navigationController.navigationBar.translucent = NO;
Or if you need to hide and then show it. You can use something like this:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}
For older iOS versions you may need to try something like this:
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
Side Note: You may also need to check with Xcode that you are placed your app components inside Safe Area widget. That would prevent this issue without any further changes.
Upvotes: 0