Reputation: 7205
I have an tabbed bar application and the status bar tint colour is set to default - so it is always my selected blue colour throughout my app.
However, in one view, I am hiding my Navigation Bar like so:
[self.navigationController setNavigationBarHidden:YES];
This is in the viewWillAppear
method and the view is accessible as it is one of the tabs of my app.
The reason I am hiding it, is because I would like to put a toolbar (with about 6 buttons) in its place.
I have set the tint colour of my toolbar, however, the status bar on this view is always black. Is there a way to re-set the status bar for this view, or is there a better way to hide the navigation bar in order to retain the status bar tint colour.
UPDATE I read somewhere that when tinting is set to default, the colour of the status bar will be the colour of the lowest pixel in the header.
I have tried hiding the navigation bar in storyboards and have also tried changing the tint colour to 'Custom' but this also had no effect.
These two screenshots might illustrate my issue. Toggling the navigation bar changes the status bar colour. This is the navigation controller which the view in question is embedded in.
Upvotes: 1
Views: 11057
Reputation: 7205
Ahh!!! I have a working solution... albeit a very dirty and makeshift solution.
Shows Navigation Bar
).Alpha
to 0 and uncheck User Interaction Enabled
- DO NOT MAKE HIDDENMake sure the Navigation Bar is on the top - as shown in following image.
This way your status bar will pick up the correct colour without showing a Navigation Bar.
Hopefully a more resilient/nicer way to do this will be in a recent Xcode update.
Top Tip: To make a toolbar look like a navigation bar:
Upvotes: 6
Reputation: 7504
If you are using iOS 6.0, you can set status bar color through plist file. See - How to set status bar tint color on iOS 6?
Status Bar
It is now possible to set status bar tint parameters in your app’s Info.plist file. You might do this to ensure that the status bar color matches your app’s navigation bar color during startup. To set the status bar tint, add the UIStatusBarTintParameters key to your Info.plist file. The value of this key is a dictionary with the appropriate values describing the navigation bar your app has at startup. Inside the dictionary should be the UINavigationBar key, which has a value that is also a dictionary. That dictionary contains the initial navigation bar’s style (with the Style key) and indicates whether it is translucent (with the Translucent key). You can also specify your navigation bar’s tint color (with the TintColor key) or the name of its custom background image (with the BackgroundImage key).
[EDIT]
It seems in iOS 6 the status bar color is automatically determined by the navigation bar color. Before hiding navigation bar can you set the color of navigation bar to your default and see if that makes any difference.
Upvotes: 1
Reputation: 4805
Change statusBarStyle of application-
[[UIApplication sharedApplication]
setStatusBarStyle:UIStatusBarStyleDefault animated:NO];
Upvotes: 0