Change UINavigationBar's color - ios

I'm using Objective-C. Here I need to change the background color of an UINavigationBar. And I tried this code below:
self.navigationController.navigationBar.backgroundColor = [UIColor greenColor];
But the result is:
What I want is change the color of the NavigationBar into the green color below instead of a blurry green as it is now. Someone please help me.

do like select your Naigation Bar on storyboard and change the property of bar tint in directly in inspector

Just add this code
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

Try to use appearance
[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
Hope this help

Related

Change tint color of buttons in activity sharing

My app uses a blueish color for the navigation bar. I set it globally in the AppDelegate like this:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0 green:0.4705882353 blue:0.7450980392 alpha:1.0]];
The problem is that when the user shares a PDF file via email with a UIDocumentInteractionController, the 'Cancel' and 'Send' buttons are also close to blue, which makes them almost invisible.
I tried:
[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:#[[UINavigationBar class]]] setTintColor:[UIColor whiteColor]];
and
[[UIButton appearanceWhenContainedInInstancesOfClasses:#[[UINavigationBar class]]] setTintColor:[UIColor whiteColor]];
This works everywhere else in my app, but not on screens presented from the UIDocumentInteractionController.
How can I change the colors of these buttons?
you need to set window tint color if you want to change color of bar button in UIDocumentInteractionController.
Add Below line of code after your code of Set NavigationBar tint color.
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0 green:0.4705882353 blue:0.7450980392 alpha:1.0]];
// Add this line...
self.window.tintColor = [UIColor whiteColor];
This is working for me.
Note : if you want to reset window tint color use below delegate of UIDocumentInteractionController.
- (void)documentInteractionControllerDidDismissOpenInMenu:controller{
// restore the tintColor which you set # app delegate
self.appDelegate.window.tintColor = [UIColor redColor];
}
Hope this will help you.

UITabBar.appearance().tintColor not changing icon colors

I'm calling UITabBar.appearance().tintColor = Constants.MAIN_COLOR in my didFinishLaunchingWithOptions but no matter what I change that color value too, my tab bar icons always appears the color of the actual image when selected. Any idea why my tab bar icons are not changing to the color defined in the code above? I made sure I wasn't calling the UITabBar.appearance() anywhere else in my project as well by doing a search.
Are you using custom icons? Then try these methods:
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
and for text:
[[UITabBarItem appearance] setTitleTextAttributes: #{ UITextAttributeTextColor: [UIColor someColor]}
forState: UIControlStateHighlighted];

In Objective C, while presenting a ViewController how to change the color of NavigationBar?

I am able to change tho color of NavigationBar by giving BackgroundColor but than I am not able change the color of StatusBar. Please provide a solution.
You should change the barTintColor instead of the background color.
[self.navigationController setBarTintColor:[UIColor redNavigationBarColor]];
Chances are that you will probably need to change also the barButton color and/or the the title color and all that should probably apply to more than one screen. So, to save you some time, if you want to globally change all these, put the code below in your app delegate
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
The code above will give you a red navigation bar with white title & buttons

Change UIActivityViewController UINavigationBar color

i tried changing UIActivityViewController by subclassing it but it never worked, also trying to set it before presenting :
activityViewController.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
Is there is any possible way to do that ? at least to change bar button item tint colors !
Note: I dont want to change my current navigationbar colors, just inside the UIActivityViewController !!
Following code maybe help you:
[[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName: [UIColor whiteColor]}];
It's code help u so try my code

Slide Menu IOS Using aryaxt/iOS-Slide-Menu

I am trying to change Navigation bar background color in viewDidLoad using the same example in the link below but that's not working.
[[UINavigationBar appearance] setBackgroundColor:[UIColor greenColor]];
please help.
https://github.com/aryaxt/iOS-Slide-Menu
To change the NAv bar color, You have to use bar tint color:
self.navigationController.navigationBar.barTintColor=[UIColor greenColor];

Resources