Cannot set prompt color in iOS11 - ios

I am trying to set the navbar prompt color in iOS11 to the same color as the navbar title color.
This works just great in iOS10:
[[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor whiteColor]}];
[[UINavigationBar appearance] setTranslucent:NO];
However this is no longer working in iOS11. The title is white but the prompt is not.
I found a thread mentioning a hack to try and get the prompt label to change via:
[UILabel appearanceWhenContainedInInstancesOfClasses:#[[UINavigationBar class]]].textColor = [UIColor whiteColor];
However that is not working either.
Anyone else experiencing this?

Seems to be a bug in iOS 11
Post on the Apple Developer forums:
https://forums.developer.apple.com/thread/85399
Radar issue (mirror) 34009213:
https://github.com/lionheart/openradar-mirror/issues/18233
It seems to be reported to Apple.

Related

Change tint color of buttons in activity sharing

My app uses a blueish color for the navigation bar. I set it globally in the AppDelegate like this:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0 green:0.4705882353 blue:0.7450980392 alpha:1.0]];
The problem is that when the user shares a PDF file via email with a UIDocumentInteractionController, the 'Cancel' and 'Send' buttons are also close to blue, which makes them almost invisible.
I tried:
[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:#[[UINavigationBar class]]] setTintColor:[UIColor whiteColor]];
and
[[UIButton appearanceWhenContainedInInstancesOfClasses:#[[UINavigationBar class]]] setTintColor:[UIColor whiteColor]];
This works everywhere else in my app, but not on screens presented from the UIDocumentInteractionController.
How can I change the colors of these buttons?
you need to set window tint color if you want to change color of bar button in UIDocumentInteractionController.
Add Below line of code after your code of Set NavigationBar tint color.
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0 green:0.4705882353 blue:0.7450980392 alpha:1.0]];
// Add this line...
self.window.tintColor = [UIColor whiteColor];
This is working for me.
Note : if you want to reset window tint color use below delegate of UIDocumentInteractionController.
- (void)documentInteractionControllerDidDismissOpenInMenu:controller{
// restore the tintColor which you set # app delegate
self.appDelegate.window.tintColor = [UIColor redColor];
}
Hope this will help you.

Change UINavigationBar's color

I'm using Objective-C. Here I need to change the background color of an UINavigationBar. And I tried this code below:
self.navigationController.navigationBar.backgroundColor = [UIColor greenColor];
But the result is:
What I want is change the color of the NavigationBar into the green color below instead of a blurry green as it is now. Someone please help me.
do like select your Naigation Bar on storyboard and change the property of bar tint in directly in inspector
Just add this code
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
Try to use appearance
[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
Hope this help

Change UIActivityViewController UINavigationBar color

i tried changing UIActivityViewController by subclassing it but it never worked, also trying to set it before presenting :
activityViewController.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
Is there is any possible way to do that ? at least to change bar button item tint colors !
Note: I dont want to change my current navigationbar colors, just inside the UIActivityViewController !!
Following code maybe help you:
[[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{ NSForegroundColorAttributeName: [UIColor whiteColor]}];
It's code help u so try my code

Use of "UINavigationBar appearance setTranslucent:NO" in iOS 7

I am Defining My UINavigationBar color code in AppDelegate with:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0f/255.0f green:87.0f/255.0f blue:10.0f/255.0f alpha:1]];
Then I also set the Translucent of my NavigationBar with:
[[UINavigationBar appearance] setTranslucent:NO];
My Project's Deployment target is iOS 7 & Target SKD iOS 8. The project got crash only when I run it on any iOS 7 device. After digging a little, I found that [[UINavigationBar appearance] setTranslucent:NO]; is not worked in iOS 7. So I want to know "Except calling it locally (in every viewController)" is there any way to use it for iOS 7 to iOS8?
Thanks a lot in advance.
You can achieve this by using a non exist image that makes fool of compiler like:-
[[UIToolbar appearance] setBackgroundImage:[[UIImage alloc] init] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
instead of:
[[UINavigationBar appearance] setTranslucent:NO];

Change ios8 Extension Navigation Bar color

I am working on iOS8 App Extension (Photo Editing Extension)
I have tried these method to update the Navigation Bar color, but failed:
[[UINavigationBar appearance] setBarTintColor:[UIColor yellowColor]];
[[UINavigationBar appearance] setTintColor:[UIColor blueColor]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor blueColor]];
It displays a default translucent gray nav bar.
Does anybody have idea on how to change the navigation bar color in iOS8 extension?
Try self.navigationController.navigationBar.barTintColor = UIColor.yellow first.
This should work for some host apps but not all. Because some host apps configure the colors in UIAppearance settings.
I found some info in here: https://pspdfkit.com/blog/2017/action-extension/#uiappearance
According to the link above, the extension will "picks up the UIAppearance settings from its host app" and this has a higher priority than the "setColor" message you send to the instance.
In this case what you can do is to modify the plist of the extension:
In NSExtension dictionary you can add a key NSExtensionOverridesHostUIAppearance and set value to YES. This will make your extension override the UIApprearance setting of the host app. Unfortunately this is only available in iOS 10 and later.
Hope you find it helpful.
Try setting the translucency of the UINavigationBar to NO like below, I believe then it should start picking up the colours
[[UINavigationBar appearance] setTranslucent:NO];
Here's the Apple Documentation for UINavigationBar translucent property
I have put your code in the appDelegate didFinishLaunchWithOption
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[UINavigationBar appearance] setBarTintColor:[UIColor yellowColor]];
[[UINavigationBar appearance] setTintColor:[UIColor blueColor]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor blueColor]];
return YES;
}
And works...

Resources