ios 6 navigation bar and status bar overlapped - ios

The problem is like this:
My status bar is intially hidden.
I have a tab bar controller and it has a navigation controller in each of its tabs.
Screen shot is like:
Later I clicked on a button on the navigation controller's view, I would like to reveal the status bar, but it ends like this:
the navigation bar overlaps the status bar. I have to perform some actions like tapping another tab to make the navigation bar go down.
I tried to set status bar to UIStatusBarStyleBlackOpaque and it worked fine.
But if I press the "home" button on iphone to turn the app to bacground and the switch back to active, the problem occurs again if I clicked on the button.

Your status bar style is UIStatusBarStyleBlackTranslucent. You should set it to either UIStatusBarStyleDefault or UIStatusBarStyleBlackOpaque for the desired effect.
Translucent status bars overlap the full screen views, while opaque ones push those views down.

click on button, do following things:
self.wantsFullScreenLayout = NO;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; //or UIStatusBarStyleDefault

Related

How to keep a Navigation Button in Navigation Bar - iOS

Please help! I am trying to place a Bar Button Item to a Navigation Bar and I would like the button to stay there between page transition. Is there any way to make this happen?
I have tried just adding the same button in the new View Controller's navigation bar, but it looks funny. It keeps the animation as if the button did not stay in place.
Thanks!

Fake Status Bar Color when Navigation Bar is hidden

I'm running into an issue with status bars & navigation bars. By default the navigation bar of UINavigationController extends behind the status bar and colors it (left screenshot).
When the search bar is used, I hide the navigation bar. This results in an uncolored Status Bar. Apple's Mail app does not have this issue.
Is there any other solution than creating a separate UIView with a background color and placing it behind the status bar?
Here's what I'd like to accomplish:
When you hide the navigationBar why don't you also update the appearance of your UIStatusBar.
Implement this function in your NavigationController:
-(UIStatusBarStyle)preferredStatusBarStyle{
//Have an if statement to determine which UIStatusBarStyle to return, i.e if the navigationBar is hidden
return UIStatusBarStyleLightContent;
}
And call it when you hide your navigation bar by using this:
[self setNeedsStatusBarAppearanceUpdate];
Another option is to do the follow:
Set UIViewControllerBasedStatusBarAppearance to NO in your info pList file.
Then you can call
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
In your IB (or programatically), try to check the simulated metrics for the top bar: you should set it from opaque to translucent (navigation bar).
Note: By default, the navigation bar is translucent. You should get the "colored"** status bar for free.
** as defined by UISearchBar.appearance().barTintColor

Getting correct color of status bar in ios

Okay I am having some trouble coloring my status bar. I have a pretty simple app that moves between two views. I tried coloring the status bars of the navigation controller with this code
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];
But it did not work until I removed the "navigation controller's" status bars and dragged status bars into the storyboard. Then I wanted the status bar to match the color so I deleted the navigation controller and it worked! I think the navigation controller status bar was not allowing the status bar to be colored correctly. However, without a navigation controller I cannot add a "push" segue. This is what it looks like with the navigation controller
And here it is without
I don't know what the solution is because I need the nav controller for this to work I think. For some reason there is no "show" option. Let me know what I should do. Thank you!
Per, http://www.appcoda.com/customize-navigation-status-bar-ios-7/ (although we are now working with iOS 8, the color of the navigation bar and status bar are the same by default. It sounds like you really do want their colors to be the same (is this what you mean by "correct color"?).
To do this in storyboard, I would add your first UIViewController to the storyboard. Click this UIViewController, go up to the menu and click Editor -> Embed in -> Navigation Controller. You will see now that the Navigation Controller is the initial scene and your UIViewController is the root view controller. Then add a second UIViewController. Ctrl drag from the first UIViewController to the second view controller and create a show (push) segue.
Now to change the color of the UINavigationController. Click of the UINavigationController (the first scene). In the outline on the left, click on the Navigation Bar. In the inspector on the right, you should see a Navigation Bar section with Style and Tint underneath. For a solid look, you can select Black Opaque and change the tint color to whatever you like. Note that your selection will roll through to your UIViewControllers. When you build the app, the status bar should now match the color of the navigation bar.

iOS 7: How to force navigation bar of UINavigationController to be laid out as if status bar is showing even when status bar is hidden

Is there a way to force the navigation bar of a UINavigationController to be laid out as if the status bar is showing even when the status bar is hidden? My motivation is to prevent the navigation bar for shifting when a navigation controller presents a view controller that returns YES for prefersStatusBarHidden. An example of this is when you look at an attached image in an email in the Gmail app.

Navigation bar with back button not hiding

I have an issue with my navigation bar.
The first screen of my app is a welcome screen, with two classic buttons in the center of the screen. No bars (tab or nav, and status is hidden with the setStatusBarHidden in the viewDidLoad). I only implemented one of the buttons but both will work the same way (the two screens are similar). So the first button loads up a "sign up" screen (a UITableViewController) with a form to fill in. There, the status bar is shown, and I added a navigation bar (in the attributes panel of my view controller), with a "send" button on the top right.
In the attributes panel of my "navigation item" (as it's called), I entered a name for the back button, which is correctly displayed (although I'd like to change the name, but I'll do it later).
My problem is that when I hit the back button, it takes me back to the "welcome" screen but the status bar is not hidden, there is a nav bar with no title and no buttons, and I can't find a way to hide them. I tried using viewDidLoad, viewDidAppear, viewDidUnload (in the sign up view) but nothing works (I can hide the status bar, but the view is loaded so there is a black space between the non-hidden nav bar and my content).
By the way, I have done most of the design using the storyboard, not with code, but I don't mind using both.
Can anybody help ? Thanks.
Hide the status bar and navigation bar in viewWillAppear: method and not in the viewDidLoad: method.If your dont want to show status bar or navigation bar,put that code in AppDelegate Class.
Edited:
This will hide your navigation bar in your View controller.Put it in viewWillAppear:
self.navigationController.navigationBarHidden = YES;
This hides your status bar.
[[UIApplication sharedApplication] setStatusBarHidden:YES animated: UIStatusBarAnimationNone];
Your view controller should have wantsFullScreenLayout set to YES, as well as hiding the status bar.Black space is showing your view is automatically didn't resized when you dont have status bar or navigation bar.you need to check auto-sizing in the storyboard "size inspector" in the right side pane tabs.
Edit 1:
This will hide your bars with animation:
[self.navigationController setNavigationBarHidden:YES animated:YES];
[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

Resources