Set NavigationBar Tint Color in iOS 7 - ios7

Am trying to set the tint for all navigation bars from my appdelegate in iOS 7. This worked always before, but for some reason now, nothing is changing. In the didFinishLaunching part of my appDelegate I have:
[[UINavigationBar appearance] setTintColor:toolbarcolor];
However, the bar stays the default translucent option.

You can set the bar tint color using the barTintColor property:
[[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]];
If you also don't want the navigation bar to be translucent, you can set the translucent property to NO.
Unfortunately, the translucent property is not available on the UINavigationBar appearance proxy, so you will have to set this property individually (in your storyboard, .xib, or in something like viewDidLoad in your controller).

Swift version:
UINavigationBar.appearance().barTintColor = colorBar

If you want to set bar tint color for whole application, write in "didFinishLaunchingWithOptions" method of AppDelegate.m
[[UINavigationBar appearance] setBarTintColor:[UIColor orangeColor]];
Following is output :

In Swift 3.0
let navigationBarAppearnce = UINavigationBar.appearance()
A navigation bar’s tintColor affects the color of the back indicator image, button titles, and button images:
navigationBarAppearnce.tintColor = UIColor.white
The barTintColor property affects the color of the bar itself:
navigationBarAppearnce.barTintColor = UIColor(red: 0.180, green: 0.459, blue: 0.733, alpha: 1.00)

Related

iOS 9: Background Image for UINavigationBar not working

I have a global background image (basically some orange color) which is set for all navigation bars inside the AppDelegate:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"order-navbar"] forBarMetrics:UIBarMetricsDefault];
This works for all views except one: I have an MFMailComposeViewController whose navigation bar background stays white-gray no matter what I do:
let mailController = MFMailComposeViewController()
mailController.navigationBar.tintColor = UIColor.whiteColor() // this works
emailController.navigationBar.setBackgroundImage(UIImage(named: "order-navbar") forBarMetrics:UIBarMetrics.Default) // this does not
UINavigationBar.appearance().setBackgroundImage(UIImage(named: "order-navbar") forBarMetrics:UIBarMetrics.Default) // this does neither
However, sometimes the mail controller appears at first with the orange bar and then suddenly changes its color to white-gray again.
On iOS 8 everything works. Is this an iOS 9 bug?

UIRectEdgeNone makes NavigationBar and Tabbar darker

I have an iOS 7 app that has a NavigationController inside TabbarController.
I then customize the bars background color
[[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
[[UITabBar appearance] setBarTintColor:[UIColor blueColor]];
It runs fine. But if there's a ViewController that wants not to be covered by the bars, like this
self.edgesForExtendedLayout = UIRectEdgeTop;
Which means this ViewController does not want to be covered by the Tabbar. But it makes the Tabbar darker than normal
I think this is because I use custom color for the bars. How to fix ?
It probably means that the there's nothing to show below the translucent tab bar. Set the tab bar translucent property to NO
#rounak is right, maybe setting the tab or nav bar's translucency to NO tells iOS not to try to put another tab or nav bar under the current one, which makes it darker.
In the viewDidLoad, add this:
self.navigationController.navigationBar.translucent = NO; // if you have a nav
self.tabBarController.tabBar.translucent = NO; // if you have a tab

SKStoreProductViewController title color

How do you change the title color and/or bar tint color in a SKStoreProductViewController?
I'm using the appearance API to set navigation bars to a dark color and the text to white. It changes the title color but not the bar tint color in my SKStoreProductViewController.
I don't think you can. At least not on iOS 7. On iOS 6 you can use the UIAppearance protocol and the SKSPVC will pick up the appearance you set on the UINavigationBar.
As noted on this thread, the SKSPVC is a remote view controller so it's inaccesible programmatically, meaning that you can't set it's appearance directly (or indirectly?).
Do the following to avoid the SKStoreProductViewController to take over a tintColor of value WHITE:
#define kCOLOR_NON_WHITE_COLOR [UIColor darkGrayColor]
// CHANGE ALL TINTING BEFORE WE CREATE An INSTANCE OF THIS BROKEN PIECE
[UIWindow appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UIView appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UINavigationBar appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UIBarButtonItem appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
// NOW CREATE THE THING
SKStoreProductViewController *controller = [[[SKStoreProductViewController alloc] init] autorelease];
This draws all the UIBarButtonItems and the UISegmentedControls in this controller in the defined color AFAIK and thus makes the controller more like your apps design.
IMPORTANT: Just do not forget(!!!) to change all the tinting back after you dismissed this controller, otherwise fresh created views in your app might take over the enforced tinting.
UPDATE: As you might already have found out the following to manipulate the appearance does not work:
[UINavigationBar appearanceWhenContainedIn:[SKStoreProductViewController class], nil]
This fix is for iOS 7 & 8 on iOS 6 you have different issues. =)

Set default tint color for all UIButtons in an app

My iPad app I has a number of UIButtons that when pressed turn blue by default. I could go through each one and set the tintcolor using:
[buttonName setTintColor:[UIColor colorWithRed:151/255.0f green:202/255.0f blue:86/255.0f alpha:1.0]];
But is there anyway of changing this colour by default and for all buttons?
Is there anyway of changing this colour?
If you are using storyboards and Xcode 5.0 or later, the easiest way to do this is to open up your storyboard in Xcode and set the Global Tint color setting in the File Inspector in the Utility area. See illustration below.
Use the UIAppearance Protocol:
[[UIButton appearance] setTintColor:[UIColor colorWithRed:151/255.0f green:202/255.0f blue:86/255.0f alpha:1.0]];
You could subclass uibutton and set the color to whatever you want there. Then any button with that class will have the same color

how to change the color of the tabbar controller

Is there any way I can change the Tab Bar Controller's color to something other than the default black? I know this isn't possible in IB, but perhaps maybe through code?
In AppDelegate
self.tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor grayColor];
In AppDelegate.m in didFinishLaunching... method write(this will change for whole app):
[[UITabBar appearance] setBarTintColor:[UIColor myColor]];
Or you can write in ViewController.m in method viewDidLoad:
[self.tabBarController.tabBar setBarTintColor: [UIColor mycolor]];
You can do with XIB/Storyboard as well as programmatically
For Xib/storyboard select tab bar controller than tab and you can see all the options to change tab bar or tab bar view properties see the attached image Image attached here
For programmatically:
for tab bar tint and background
[[UITabBar appearance] setTintColor:panelColor];
[[UITabBar appearance] setBarTintColor:[UIColor lightGrayColor]];