Change UINavigationBar Tint Color - ios

Hi I am trying to change the tint color of a newly created navigation bar but i am having difficulty getting the tint color to change and have tried various ways of implementing tintColor. Here is how I am creating it.
UINavigationBar *navBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 64)];
[navBar setTintColor:[UIColor redColor]];
[settingsView addSubview:navBar];
Do I need to approach it differently or redraw it?

Can you try this,
[navBar setBarStyle:UIBarStyleBlackOpaque];
[navBar setTintColor:[UIColor redColor]];

iOS 7 Has a method called setBarTintColor which works perfectly

Worked perfectly for me!
[self.homeNavigationBar setBarTintColor:[UIColor whiteColor]];

Try this:
[[UINavigationBar appearance] setBarTintColor:[UIcolor redcolor]];

use this code
UIColor *appcolor=[UIColor colorWithRed:63.0/255.0 green:148.0/255.0 blue:246.0/255.0 alpha:1.0];
[[UINavigationBar appearance] setBarTintColor:[UIColor appcolor]];

Related

In Xcode 13 [[UINavigationBar appearance] setBarTintColor: not working properly?

I have updated my Xcode into 13, later on words in my old project navigation and tab bars colours was changed to transparent.
My Code is
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
I tried to add background colour but title and images of the navigationBar not appering.
self.navigationController.navigationBar.backgroundColor = [UIColor bOneAppThemeColor];
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
I have studied this below link but i'm unable to implement it in Objective C
https://developer.apple.com/forums/thread/682420
Almost everything you're doing is wrong (and has been wrong for several years). You need to use UINavigationBarAppearance (and UITabBarAppearance) and apply them to both the bar's standardAppearance and its scrollEdgeAppearance. Set the appearance's background color, not its tint color. And do not touch the translucent property ever.
In this simple example, we make all navigation bars adopt your theme color. Modify to suit your needs and desires:
if (#available(iOS 13.0, *)) {
UINavigationBarAppearance* appear = [UINavigationBarAppearance new];
appear.backgroundColor = [UIColor AppThemeColor];
id proxy = [UINavigationBar appearance];
[proxy setStandardAppearance: appear];
[proxy setScrollEdgeAppearance: appear];
} else {
// Fallback on earlier versions
}

UINavigationBar background color not the exact UIColor that is set it to

I am using this color code #142148.
OutPut top bar view
[[UINavigationBar appearance] setBarTintColor:Default_blue_color];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackOpaque];
I think tint is just a tint, not an exact color.

Remove Navigation Bar shadow Colour on iPhone 6/6plus

I'm trying to remove this white stroke. I've previously fixed this using
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
and it work perfectly on iPhone 4s,5,5s and iOS 7/8. But for some reason on iPhone 6/6+ that whte shadow is still there.
I've also tried this to no result. It just makes the shadow a darker colour than my current navBar bgColour (white: 0 alpha 0.9).
UIView * bgView = [[UIView alloc] initWithFrame:CGRectMake(0, self.navigationController.navigationBar.height, self.navigationController.navigationBar.width, 1)];
bgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.9];
[self.navigationController.navigationBar addSubview:bgView];
[self.navigationController.navigationBar setShadowImage:nil];
Any ideas?
Try doing the following, this at least works for me.
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
I also then set a custom colour
[[UINavigationBar appearance] setBarTintColor:[UIColor XXXXXX]];
Try to set navigation's bar property clipsToBounds to YES

Changing UINavigationBar color issues

I am having issues modifying color on a UINavigation bar. I feel like I have tried everything, but my current code is below (MasterViewController.m, my main view):
-(void)awakeFromNib{
[super awakeFromNib];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.9333 green:0.3647 blue:0.3843 alpha:1.0]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:0.9333 green:0.3647 blue:0.3843 alpha:1.0]];
[[UINavigationBar appearance] setTranslucent:NO];
}
Here is my setup in my storyboard:
Any apparent reason why this isn't working?

How to set UISwitch border color?

My app has:
[[UIView appearance] setTintColor:[UIColor whiteColor]];
And here is what I have when on:
and off:
I need to make UISwitch border visible like in Settings.app:
Your [[UIView appearance] setTintColor:[UIColor whiteColor]]; is interfering with the tint color of your switch. The command to set the tint color is self.mySwitch.tintColor = [UIColor grayColor]; which sets the color used to tint the outline of the switch when it is turned off.
Will you please try adding this line to your AppDelegate's didFinishLaunchingWithOptions
[[UISwitch appearance] setTintColor:[UIColor grayColor]];
This should apply the chosen Tint color on all your UISwitch controls.
Rather than using the appearance proxies you can also use:
[self.mySwitch setThumbTintColor:[UIColor blueColor]];
[self.mySwitch setOnTintColor:[UIColor redColor]];
ie. Use setOnTintColor for the background/border color.

Resources