Change Navigation Bar text colour - ios

I would like to change the status bar text (the text at the top of the screen with the time, battery percentage, etc) to white. How can I do this?

If your view controller is within a navigation controller, in the view controller's .m , use this line in your viewDidLoad:
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

Related

is it possible to apply two navigation colors for two view controller in iOS

i have situation where i need to have blue color as navigation bar color for first view and for second view i should have as green color .when i tried to apply it using below code.
in viewdidload for 1st view:
self.navigationController.navigationBar.barTintColor = [UIColor bluecolor];
in view did load in second view:
self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
the color remains same as in first view i was unable to change it,and how to remove glassy effect on navigation bar.
Select your navigation controller in your view hierarchy(in Storyboard), select the navigation bar and from there you can set the color in the attributes inspector.

How to add Navigation bar to view controller with tab bar item

I have an app that uses bottom tabs aswell as a side menu, to have the button that initiates the side menu i use the typical three line menu button, to put that there I have a Navigation Bar. With the bar in place there is no way I can get the bar to be on top of the screen. I built it with interface builder, and heres a screenshot. The question is how do i have the navigation bar alone without the other grey bar above it?
The issue you're encountering is due to the fact that you're manually creating a navigation bar for your view controller, instead of using the bar that you get for free by embedding the view controller in a tab bar controller, hence the reason you see two bars. The other answer suggesting hiding the auto-generated navigation bar is not the correct solution. Instead, you should place your menu button and view title in the auto-generated bar instead of manually creating your own (you almost never want to do that, in-fact).
So what you should do instead is set the title property of your view controller to be "News", and the leftBarButtonItem property of the view controller to be your hamburger menu button (an instance of UIBarButtonItem initialized with an image for the icon).
For example (inside your view controller's viewDidLoad method or wherever appropriate):
self.title = #"News";
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"menuIcon"] style:UIBarButtonItemStylePlain target:self action:#selector(showSideMenu)];
If you want to remove the topmost navigation bar you need use self.navigationController.navigationBarHidden = YES; for view controllers that used for tabs in UITabBarController:
// StoriesViewController.m
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}

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.

alternating between toolbar / tab bar

my app is structured as follow: UITabBarController > UINavigationController > ViewControllerOne > ViewControllerTwo.
the UINavigationBar has at the bottom the tab bar, now when the user navigates into the second view controller, i want to be able to hide the tab bar and replace is with a tool bar. i tried this code:
[self.navigationController.tabBarController.tabBar setHidden:YES];
[self.navigationController.toolbar setHidden:NO];
when i run the app the tab bar is hidden but the toolbar doesn't appear. plus, since the last VC is a table view controller, when i scroll through the cells there is a white gap between the table and the bottom of the view. how can i fix that?
That won't work because when you hide the tab bar like that the subviews won't be adjusted properly (that's why you get the white space). You'll have to use
self.hidesBottomBarWhenPushed = YES;
In your init method or awakeFromNib... and then
[self.navigationController setToolbarHidden:NO animated:YES];
In the viewDidLoad for example.
That way the tab bar controller's view is going to layout correctly it's subviews when you hide the tab bar. Just remember to call self.hidesBottomBarWhenPushed = NO; in your first view controller otherwise the tab bar is still going to be hidden when the second view controller is popped from the navigation stack.
Try to assigning toolbar with appropriate frame and adding it to self.tabBarController.view

remove toolbar from navigation controller

I have a navigation controller where I add a toolbar based on user input.
When the user hits back to the home screen. I don't want the toolbar.
self.navigationcontroller.toolbar.hidden = YES;
This just hides the toolbar and the UIImage on the homepage is now shifted up the 40px and the black background appears where the toolbar is hidden.
How can I REMOVE the toolbar so the image doesn't get pushed up.
self.navigationController.toolbar.hidden = YES;
needed to be replaced with...
self.navigationController.toolbarHidden = YES;
To keep the position of the child VC's frame move it with 40px down (animation with duration 0.25 f.e.), when you hide the toolbar, or change the navigation controllers bounds origin with origin.y+40, just like you would do, when you are hiding the status bar. But i think an empty space will remain, you should do something with it.
For swift you need to write:
self.navigationController?.isToolbarHidden = true

Resources