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

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

Related

Cannot set prompt color in iOS11

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.

Change 1Password App extension navigation bar title color

I am trying to change the color of navigation bar title and status bar items in 1Password App extension. I am unable to find a way to do it.
Please the image below.
There must be a way to do it, Uber app is doing it. Please find the image below.
Can some one please suggest me a way to do it.
change navigationBar title color:
self.navigationController.navigationBar.titleTextAttributes = #{NSForegroundColorAttributeName:[UIColor grayColor]};
change status bar font color:
1.in the Info.plist add item: UIViewControllerBasedStatusBarAppearance NO
2.add the code in [viewController viewDidLoad]
tip:if you need change all viewController status font color,you should add in [AppDelegate application:didFinishLaunchingWithOptions:]
[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Before presenting 1Password screen set the appearance as follows.
[[UINavigationBar appearance] setBarTintColor:nil];
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
[[UIBarButtonItem appearance] setTintColor:[UIColor blackColor]];
[[UINavigationBar appearance] setTitleTextAttributes: #{NSForegroundColorAttributeName:[UIColor blackColor]}];
In completion block of 1Password reset your appearance to your app sepecific appearance.

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...

How put navigationBar backgroundImage without opacity in ios 7?

Hi I have navigationBar with image in ios 7 [xcode 5].
When I run my application my navigationBar auto be blur.
I want to chenge it to regular [no blur].
my code:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"nav_bg.png"] forBarMetrics:UIBarMetricsDefault];
I try add this code but the apps crash:
[[UINavigationBar appearance] setTranslucent:NO];
What need I do to make all my navigation bars in app to regular?
thank
If you are using storyboard you can set it here
If you need to set it in code use
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
in your viewDidLoad

UINavigationBar appearance setBackgroundImage:nil doesn´t work on ios 5.1

i set my UINavigationBar appearance with the following line:
UIImage *navigationBarBackground = [UIImage imageNamed:#"HeaderNavBar.png"];
[[UINavigationBar appearance] setBackgroundImage:navigationBarBackground forBarMetrics:UIBarMetricsDefault];
I remove it with the following line:
[[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
This works on every ios, except on ios 5.1...Does somebody know why?!
"When the contents of your view change, you do not redraw those changes directly. Instead, you invalidate the view using either the setNeedsDisplay or setNeedsDisplayInRect: method." (View Programming Guide). Do you still have that issue after redrawing the view?
See also: UIView Class Reference: setNeedsDisplay
[[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:navigationBarBackground forBarMetrics:UIBarMetricsDefault];
and then:
[[UINavigationBar appearanceWhenContainedIn:[self class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
It is recommended here.

Resources