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

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.

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
}

Why my tabbar was rendered with gray rect?

// Tabbar
// Icon inactive
[[UITabBarItem appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor darkGrayColor]} forState:UIControlStateNormal];
// Icon active
[[UITabBar appearance] setTintColor:PRIMARY_COLOR];
// Text active
[[UITabBarItem appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName: PRIMARY_COLOR} forState:UIControlStateSelected];
// Background
[[UITabBar appearance] setBarTintColor:WHITE_COLOR];
// Over View YES/NO
[[UITabBar appearance] setTranslucent:NO];
I've a gray rect around the text and the icon.
Why? Where my damn mistake?
After discussion, we find that #CeccoCQ used another setting for UIView. That makes every view have a custom background color (in the image, it's gray color).
[[UIView appearance] setBackgroundColor:WINDOW_BACKGROUND_COLOR];
To resolve the problem, remove this custom setting and everything will work fine.

How to set a different unselected image and text color on UITabBarItem

I'd like to set different colors for a UITabBarItem's title text and image in the unselected state.
For the selected state, I can accomplish this like so:
[[UITabBar appearance] setTintColor:[UIColor purpleColor]]; // image color
[[UITabBarItem appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName: [UIColor orangeColor] } forState:UIControlStateSelected]; // text color
For the unselected state, I'm attempting the following:
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blueColor]]; // image color
[[UITabBarItem appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName: [UIColor redColor] } forState:UIControlStateNormal]; // text color
But for some reason, the unselectedItemTintColor setting overrides whatever I try and set for the titleTextAttributes – so in the snippet above, both the text and image would appear blue.
I've also tried changing the titleTextAttributes directly on the UITabBarItem after I've created it (instead of using appearance), but again this seems to have no effect.
How can I achieve different unselected colors? Is it possible?
I managed to solve this shortly after posting. It turns out that while setting the unselectedItemTintColor using UIAppearance overrides the titleTextAttributes for the item, everything works correctly if you set the unselectedItemTintColor directly on the tab bar itself.
So instead of
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blueColor]];
just do
[self.myTabBarInstance setUnselectedItemTintColor:[UIColor blueColor]];

iOS 7 customize text color of quick view launched from document interaction controller

I'm developing an iPhone app.
I have set the color of the navigation bar to blue, and the text to white using
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
nil]];
in the delegate.
In a view controller I use a Document interaction controller to share a pdf, but when I choose to print it, or to open with Quick Look, those apps are presented with the standard white navigation bar of the system, but with the text in white, which makes the title and the buttons unreadable.. how can i fix this?
I've already tried to take a look at the methods of the UIDocumentInteractionControllerDelegate, but I couldn't find a solution..
This is how the print view appears:
In iOS 7 you can set UINavigationBar color by calling this in delegate class,
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:65.0f/255.0f green:95.0f/255.0f blue:156.0f/255.0f alpha:1]];
And of course the title color by calling this,
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,nil]];
But always make sure when you set UINavigationBar color, check the os compatibility wheres we have to use different method in iOS 6 and below, And you can achieve that like this,
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:65.0f/255.0f green:95.0f/255.0f blue:156.0f/255.0f alpha:1]];
}else{
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:65.0f/255.0f green:95.0f/255.0f blue:156.0f/255.0f alpha:1]];
}

Change UINavigationBar Tint Color

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]];

Resources