iOS13 - Problem with navigationBar title color

Hi,


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.tabBarControllertitle = 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]];


I hope anyone has an idea how to change the title color back to white. Best case without adjust every controller.

Accepted Reply

I found the correct answer. The code looks now like this:


if (@available(iOS 13, *))
{
    UINavigationBarAppearance *navBar = [[UINavigationBarAppearance alloc] init];
    navBar.backgroundColor = COLOR_HEADER_LIGHT;
        
    [navBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                    COLOR_TEXT_WHITE, NSForegroundColorAttributeName, nil]];
                                        
    self.navigationController.navigationBar.standardAppearance = navBar;
    self.navigationController.navigationBar.scrollEdgeAppearance = navBar;
}

Replies

I found the correct answer. The code looks now like this:


if (@available(iOS 13, *))
{
    UINavigationBarAppearance *navBar = [[UINavigationBarAppearance alloc] init];
    navBar.backgroundColor = COLOR_HEADER_LIGHT;
        
    [navBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                    COLOR_TEXT_WHITE, NSForegroundColorAttributeName, nil]];
                                        
    self.navigationController.navigationBar.standardAppearance = navBar;
    self.navigationController.navigationBar.scrollEdgeAppearance = navBar;
}

This helped a lot - I was struggling with that for weeks. Many thanks! Actually the problem no longer exists in iOS 13.1, which means that the underlying issue was a bug in iOS 13.0.

I am facing the issue for UITabbarItem. Which color is grayed out. can you tell in swift 5 what will be the solution?