I have a storyboard-app with several viewControllers and a tabBarController. Up to now the color of the title of the navigationBar was white. Now I'm testing with Xcode 11 beta 6 an iOS 13 beta 8 and the title are black. On devices with iOS 12 the title are still white. I tried to set title color in the navigation bar of the navigation controller in the storyboard. But this makes no difference. I also tried to change the title color in every view, but sometimes it doesn't work. At the beginning of testing with iOS 13 I had to change my code for changing the backgroundcolor of the statusbar. The code is this:
self.tabBarController.title = NSLocalizedString(@"AppTitle",nil);
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor clearColor];
shadow.shadowOffset = CGSizeMake(0, 1);
[self.navigationController.navigationBar setBarTintColor:COLOR_HEADER_LIGHT];
if (@available(iOS 13, *))
{
UINavigationBarAppearance *navBar = [[UINavigationBarAppearance alloc] init];
navBar.backgroundColor = COLOR_HEADER_LIGHT;
self.navigationController.navigationBar.standardAppearance = navBar;
self.navigationController.navigationBar.scrollEdgeAppearance = navBar;
}
else
{
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = COLOR_HEADER_LIGHT;
}
}
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
shadow, NSShadowAttributeName, FONT_MEDIUM_SIZE_18, NSFontAttributeName,
COLOR_TEXT_WHITE, NSForegroundColorAttributeName, nil]];
[self.navigationController.navigationBar setTintColor:COLOR_TEXT_WHITE];
I hope anyone has an idea how to change the title color back to white. Best case without adjust every controller.
The text color of the navigation bar can be changed using two inbuilt classes: navbar-light: This class will set the color of the text to dark. This is used when using a light background color. navbar-dark: This class will set the color of the text to light.
This change was brought in after the Android-maker launched the Pixel 2 and Pixel 2 XL – both the phones came with displays featuring variants of LED technology. As such, having a black navigation bar with white navigation buttons was leading to burn-in issues.
The appearance settings for the navigation bar when the edge of scrollable content aligns with the edge of the navigation bar.
func manageNavigationBar(){
if #available(iOS 13.0, *){
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
navBarAppearance.backgroundColor = UIColor(red: 0.6157, green: 0.3412, blue: 0.8588, alpha: 1.0)
navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance(whenContainedInInstancesOf: [UINavigationController.self]).standardAppearance = navBarAppearance
UINavigationBar.appearance(whenContainedInInstancesOf: [UINavigationController.self]).scrollEdgeAppearance = navBarAppearance
}
}
//call this function in your AppDelegate also in a class where you want navigation to work like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With