Change color of ios8 navigation bar

I am working on the iOS8 extension (photo editing extension)

I tried this method to update the color of the navigation bar, but failed:

[[UINavigationBar appearance] setBarTintColor:[UIColor yellowColor]]; [[UINavigationBar appearance] setTintColor:[UIColor blueColor]]; [[UINavigationBar appearance] setBackgroundColor:[UIColor blueColor]]; 

Displays the default translucent gray navigation bar.

default nav. color

Does anyone have any ideas on how to change the color of the navigation bar in iOS8 extension?

+8
ios objective-c ios8
source share
3 answers

First try self.navigationController.navigationBar.barTintColor = [UIColor yellowColor]; . This should work for some host applications, but not for all. Because some host applications adjust colors in the UIAppearance settings.

I found the information here: https://pspdfkit.com/blog/2017/action-extension/
According to the link above, the extension will β€œcollect UIAppearance settings from its host application,” and this has a higher priority than the β€œsetColor” message that you send to the instance.

So what you can do is configure the plist extension:
In the NSExtension dictionary NSExtension you can specify the NSExtensionOverridesHostUIAppearance key and set the value to YES . This will force your extension to override the UIAppararance setting for the host application. Unfortunately, this is only available in iOS 10 and later.

We hope you find this helpful.

+4
source share

Try setting the transparency of the UINavigationBar to NO , as shown below, I believe that it should start picking colors

 [[UINavigationBar appearance] setTranslucent:NO]; 

Here's the Apple Documentation for the UINavigationBar translucent property

0
source share

I put your code in 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 working...

enter image description here

-2
source share

All Articles