Hide UINavigationBar but still show Status Bar - ios

How can I hide the navigation bar by not hiding the status bar in my app? When I try [self.navigationController.navigationBar setHidden:YES]; it also hides the status bar. I need to show the status bar like this:
I need to first hide a visible navigation bar, make the status bar still visible and I also have a view that I need to move below the status bar, but the view is being positioned like the navigation bar is still there when I set the frame's position to 0,0.
I setup my statusbar as:
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

Add this to your code where you want to hide the navigation bar
[self.navigationController.navigationBar setHidden:YES];

If you want to hide navigation bar but show status bar, you should set Top Space to Top Layout Guide as 0 instead of -44. and then
Hide navigation bar in viewWillAppear instead of viewDidLoad: [self.navigationController setNavigationBarHidden:YES animated:YES]
I start to set top space as -44, then call method [[UIApplication sharedApplication] setStatusBarHidden:NO], it doesn't work.

In my case, the status bar text and symbols were not shown because they had the same color as the background (black). I solved the problem by changing the background color:
[self.navigationController.navigationBar.superview setBackgroundColor:UIColor.whiteColor];

Related

IOS status bar not translucent

I have a navigation view controller. The root view hides the navigation bar using self.navigationController?.navigationBarHidden = true.
No matter what I do I cannot get thestatusBar to be translucent it is simply a white block that pushes my content below.
You can make status bar translucent as -
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
// set full screen layout in view controller class
self.wantsFullScreenLayout = YES;

Set status bar colour for different view controllers

I have 6 view controllers. I'd like to set the status bar of my first view controller to black and then the other 5 to white. All view controllers are in a push stack.
I've tried to implement
[self setNeedsStatusBarAppearanceUpdate]
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
That does not seem to work. I've also tried playing with the apps plist properties. Any ideas?
If you want to change Background colour of status bar then that's possible.
you have to change UIWindow 's background colour to your preferred colour. try following
e.g.
[[UIApplication sharedApplication].delegate window].backgroundColor = [UIColor orangeColor];
and if you want to change text colour then just try
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
You have missed this settings in Plist
View controller-based status bar appearance to YES
Do the following things.
View controller-based status bar appearance = NO in plist.
The ViewController that you want to make white in ViewwillApper add
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
The ViewController that you want to make Black in ViewwillApper add
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

UINavigationBar has wrong height because the status bar is hidden while loading

I have set a UITabBarController as the root view controller in the AppDelegate.
I have added a loading view upon the window, while the app downloads some data. I have hidden the status bar while the loading screen is visible. As soon as the loading is done, I fade the loading view and shows the status bar again.
My problem is that when I show the status bar the navigation bar was not drawn to have the right height, because the status bar was hidden when it was drawn. If I change to another tab it gets the right height.
I have tried with [navigationController.view setNeedsLayout], but that seems to get the position of the view of the ViewController right, but the content of the navigation bar does not resize. I have also tried with [navigationController.navigationBar setNeedsLayout], but that does help at all.
So I basically want to get the navigation drawer get the right height for the status bar and content when the loading view fades. How can I do this?
Have you try to reset the navigation and status bar as like below?
-(void)resetNavigationBar
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO];
}
I would unhide the status bar in the viewWillDisappear: method on the loading view.
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}

UIModalViewController StatusBar background color

I set an UINavigationBar background tint by appearance using macro color:
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x6DBEE8)];
And in whole navigation based application but in my UIModalViewController does not work:
In my plist i have : View controller-based status bar appearance : YES
and globally i set appearance : [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Here it what it's look like:
That is because in iOS7, the height of UINavigationBar is increased (64 points) when it is contained in a UINavigationController. With the status bar being transparent,when you are presenting a view controller modally, its not in the UINavigationController so the height is normal (44 points) and thus the map view is behind the status bar. You need to handle this in your modal view controller. You can:
Hide the status bar altogether (works but might not be preferable in
every situation)
Put a view behind the navigation bar and where the status bar is with
the same background color.
Change the color of the view controller's view itself to the desired color and
offset the y position of your map view to accommodate the status
bar's height.

Top bar color when keyboard is dismissed during search

I have light top bar colors in my app, because the navigation bar is dark brown:
When I tap search (Keresés here), the following code sets the top bar color to dark content:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
So it looks like this:
But when I type something into the field, then scroll the results list, the keyboard dismisses and the top bar is reverted to white. How can I prevent this?
In iOS 7, the status bar style is, by default, determined by the return value of the UIViewController method -preferredStatusBarStyle. The default implementation of this method returns UIStatusBarStyleDefault.
Setting the info.plist key UIViewControllerBasedStatusBarAppearance to the value of NO returns to the pre-iOS 7 style of taking the status bar appearance from the shared UIApplication object
To fix this you have two options:
1) Implement the -preferredStatusBarStyle method in all your view controllers that want the status bar style to be non-default
2) Add the key "View controller-based status bar appearance" (UIViewControllerBasedStatusBarAppearance) to your info.plist file and set its value to NO
The solution is in this comment: https://stackoverflow.com/a/19513714/511878
Summary: UINavigationController does not forward -preferredStatusBarStyle to it's children.

Resources