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

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
}

Related

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.

Navigation bar Background not showing color

I am using MFMailComposeViewController for sending mails.
I have cutomise set the navigation bar with blue color
But issue is that its working fine in my simulator and ipod 5 but color of navigation not showing in iphone 5
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"Topbar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:#"SinkinSans-400Regular" size:17],
NSFontAttributeName, [UIColor whiteColor],NSForegroundColorAttributeName,
[UIColor whiteColor],NSBackgroundColorAttributeName,nil]];

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?

DocumentInteractionController Navigation Bar Color

In my iOS application, I am using the DocumentInteractionController to preview the .csv document.
self.documentController = [UIDocumentInteractionController interactionControllerWithURL:fileLocation];
[self.documentController setDelegate:self];
[self.documentController presentPreviewAnimated:YES];
However, I am finding that the navigation bar is completely transparent. The back button is white, so it is not visible due to the white background.
Note that I have styled the navigation bar in the AppDelegate:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0/255.0f green:138/255.0f blue:188/255.0f alpha:1.0f]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSFontAttributeName:[UIFont fontWithName:#"DINPro-Bold" size:17]}];
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[UIImage imageNamed:#"shadow"]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
Essentially, my question is how can I make the appearance of the navigation bar in the DocumentInteractionController View Controller consistent with the appearance of the navigation bar throughout the entire app (or at least visible!).
This line puts a transparent (or rather void) background image to your UINavigationBar. Why is that?
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
Just remove the line and everything works well.
If you want to set a shadow image, then you should think about using appearanceWhenContainedIn: instead of appearance so it won't spread to unhandled controllers.
As for the Status Bar Style, the simplest way would be to pass self.navigationController as the presenter, instead of self:
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self.navigationController;
}
Hope this will help,

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

Resources