StevenYung StevenYung - 6 months ago 28
iOS Question

UIBarButtonItem setTintColor white but when run in a real phone it change to gray

I set the

UIBarButtonItem
tintColor
to white, It is white appearance in storyboard and the simulator´╝îBut when run in a real phone it comes to gray! Why are so strange?

In real phone:
enter image description here

Simulator:
enter image description here

Also When set a
UIBarButtonItem
image has the same problem

In real phone:

enter image description here

In Simulator:

enter image description here

Answer

you can assign this concept in multiple ways to barButtonItem

Choice-1

[UINavigationBar appearance].barTintColor = [UIColor redColor];
[UINavigationBar appearance].tintColor = [UIColor whiteColor];

Choice-2

[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];

Choice-3

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if([UINavigationBar conformsToProtocol:@protocol(UIAppearanceContainer)]) {
    [UINavigationBar appearance].tintColor = [UIColor whiteColor];
}

return YES;
}

Choice-4

 self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

Choice-5

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.tintColor = [UIColor whiteColor];
return YES;
}