How to make view go under navigation bar - ios

In iOS 11, when the navigation bar is shown (after having been hidden), the entire view below it moves down. How can I stop this from happening?
Nav bar hidden:
Nav bar showing:

set the transparency of navigation to false.
self.navigationController?.navigationBar.isTranslucent = false;

Related

UINavigation bar not getting cleared in swift3 Xcode

I am trying to achieve a transparent navigation bar such that the background image is shown clearly. Currently i have used a base controller class where i have put a code for transparent navigation bar:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.view.backgroundColor = .clear
But currently i am getting the clear navigation bar only on first page. If i push and go to the second controller i can see a empty white space.
See the below images:
First page with cleared navigation bar
Second page with empty white space at the top
Why the navigation bar is not getting transparent? Any ideas?
As Your navigation bar is transparent, it will show your viewcontroller's view background color.
I think, your second page view controller's view background color is White. Thats the reason you are getting white color.
Add Top Constraint to SuperView, Not to TopLayout Guide
change the view background
self.navigationController?.navigationBar.isTranslucent = true
For more detail about isTranslucent read this doc
https://developer.apple.com/documentation/uikit/uinavigationbar/1624928-translucent

when navigationBar.isTranslucent is true, the backgroundImage of navigationbar become translucent too

In my first page, the navigation bar should be transparent, and when push to next page, the navigation bar should be a image. I worked it out by changing the _UIBarBackground or _UINavigationBarBackground's alpha.
But I meet a big problem, in the first page, view should be placed and draw from (0,0) so I set the navigation bar's isTranslucent to true, that all works fine. But when I enter the next page, background image shows with a translucent looking which I don't want.
btw, I set background using:
navVC.navigationBar.setBackgroundImage(UIImage(named: "navigation_bar_background"),
for: .default)
I checked the image used here, and it's not translucent.
What can I do with this issue? I don't want set viewController's extendedLayoutIncludesOpaqueBars to true due to ugly appearance when animation.
Combination of these 2 solutions will help.
http://ioscodeguide.blogspot.in/2014/01/navigation-bar-bagground-image.html
http://ioscodeguide.blogspot.in/2014/01/navigation-bar-font-style-and-font.html
In first view:
self.navigationController.navigationBar.tintColor = [UIColor clearColor];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
In 2nd view:
Set image to your navigationBar using the following link.
How to set Navigation Bar Bagground image - By - iOSCodeGUIDE
Adding to that
To keep navigation bar transparent in first page and display on 2nd page,
1st Page viewwill appear Hide-Yes NavigationBarHide, and on view did disappear Hide-No

UINavigationBar Transition

Currently, I am having an issue with the transition of two navigation bars. The root view has a transparent navigation bar, while the other navigation bar is opaque with a bar tint color. This is what is currently going on:
https://youtu.be/xfpNnjfOMRc. As you can see, the transparent navbar blinks. The transparent nav bar has this line of code: self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default).
To go about solving this issue, I added this block of code to the second view controller (with the bar tint color):
override func willMoveToParentViewController(parent: UIViewController?) {
super.willMoveToParentViewController(parent)
if parent == nil {
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
}
}
Now however, this happens: https://youtu.be/oMLL0v9_9Yc. When the back button is pressed, the nav bar of the second view controller is rendered transparent, solving the issue above. However, this is not the ideal solution. I simply want a smooth transition between the two nav bars. Ideas?

dismiss view controller UINavigationBar overlaps with status bar?

When I dismiss viewcontroller Navigation bar overlaps with status bar how to solve this issue ?
self.navigationController?.navigationBarHidden = true
add this code in your first view Controller

Prevent UISearchDisplayController from hiding under the navigation bar on iPad

I have a tableview with view with search bar on top of the screen below navigation bar. There is also tab bar on this screen. When search controller is activated first, time search bar hides under navigation bar (Translucent set to NO).
In viewDidLoad, searchDisplayControllerDidEndSearch and searchDisplayControllerWillBeginSearch I am setting the search bar frame:
self.searchDisplayController.searchBar.frame=CGRectMake(0, 0, width, 44);
I am not using AutoLayout

Resources