-1

The minimum target of my app is iOS 26, and used default navigation bar with buttons throughout the app. Since iOS 26, I’ve noticed that the UIBarButtonItem text color changes on some screens. Earlier, the Save button title was not visible because both the background and the text were white. To fix this, I set the UIBarButtonItemAppearance (normal & highlighted) text color to UIColor.label, which now makes the titles visible on all screens—whether the background is white or black.

If I set the text color to only white or black, it won’t work consistently because different screens use different backgrounds. Using UIColor.label is currently the only stable solution. Now I want to make the bar button background color consistent across the entire app.

I haven’t added any screen-specific code. The navigation appearance is configured in AppDelegate just left/right buttons are set in viewcontroller viewWillAppear Check navigation buttons

func setupNavigationBar() {
        let appearance = UINavigationBarAppearance()
        appearance.configureWithOpaqueBackground()
//        appearance.configureWithDefaultBackground()
        appearance.backgroundColor = Constants.Colors.DARK_NAVIGATION
        appearance.titleTextAttributes = [.font: UIFont.boldSystemFont(ofSize: 18.0),.foregroundColor: UIColor.white]
        
        // Customize back button font size and color for Large Text
        let backButtonAttributes: [NSAttributedString.Key: Any] = [
            .font: UIFont.boldSystemFont(ofSize: 18.0),
            .foregroundColor: UIColor.white
        ]
        appearance.backButtonAppearance.normal.titleTextAttributes = backButtonAttributes
        appearance.backButtonAppearance.highlighted.titleTextAttributes = backButtonAttributes
        
        // Button appearance
        let buttonAppearance = UIBarButtonItemAppearance()
        buttonAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.label]
        buttonAppearance.highlighted.titleTextAttributes = [.foregroundColor: UIColor.label]
        appearance.buttonAppearance = buttonAppearance

        UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self] ).tintColor = nil
        UINavigationBar.appearance().standardAppearance = appearance
        UINavigationBar.appearance().scrollEdgeAppearance = appearance
        UINavigationBar.appearance().compactAppearance = appearance
        UINavigationBar.appearance().tintColor = .white // ensures back chevron + bar button icons are white
    }
New contributor
Ajay Nai is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.