How to debug navigationcontroller.tintColor not changing?

For some reason I can't figure out why I'm not able to change the tintColor of my navigation bar buttons in my app and I don't know how to figure out why. Can you recommend how I can debug this issue?

I am adding this to the viewDidLoad of my view controller:

UINavigationBar.appearance().tintColor = .green

However, nothing changes and the back button and Aa bar button stay the default grey color.

The navigation + status bars are translucent and sit on top of the background color of the viewcontroller through out the app.

I am able to change the barbutton to .green in a test app where I do the exact same (add it to ViewDidLoad of a vc, make sure that the barbutton images assets are set to Template so they'll take on the color I set). But for whatever reason, that same thing won't change in my app prototype.

Are there are any common reasons for this that I might not know of?

Added: the bar button was added via storyboard only.

And here is the code attempt to change its color via the viewDidLoad of 1 viewcontroller:

Class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        UINavigationBar.appearance().tintColor = .green
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
        self.navigationController?.navigationBar.shadowImage = UIImage()
        self.navigationController?.navigationBar.isTranslucent = true
    }

}

If you want to use the global appearance() proxy, then you can't do it in your view controller.

If you want to change the tintColor in viewDidLoad of your view controller then you have to set it on your controller's navigationController instance directly:

navigationController?.navigationBar.tintColor = .green

To use the appearance() proxy, and set a global tintColor for navigation bars, you'll have to do it before your navigation controller is initialized.

For example, it will work if you do it in your app delegate's application(_:didFinishLaunchingWithOptions:):

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    UINavigationBar.appearance().tintColor = .green
    return true
}

See the UIAppearance documentation for details of why this is:

https://developer.apple.com/documentation/uikit/uiappearance

"iOS applies appearance changes when a view enters a window, it doesn’t change the appearance of a view that’s already in a window. To change the appearance of a view that’s currently in a window, remove the view from the view hierarchy and then put it back."

iOS Dark Mode UINavigationBar not updating back |Apple , I verified that the label is still there and still white using the Debug View Heirarchy within xcode. UINavigationController (opaque top bar) - This is really non-​functional because the title color is changed, but the bar color is not changing. From the Build menu, select Configuration Manager, then select Debug or Release. On the toolbar, choose either Debug or Release from the Solution Configurations list. Generate symbol (.pdb) files for a build (C#, C++, Visual Basic, F#) You can choose to generate symbol (.pdb) files and what debug information to include. For most project types

Navigation Bar color

To change the background color of the navigation bar, use the below code

navigationController?.navigationBar.barTintColor = .green

Change .green with your desired color.

Navigation Bar Text Color

navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.green]

Change .green with your desired color.

Setting iOS Navigation background color not working correctly, Setting iOS Navigation background color not working correctly - ios. imageFromColor(UIColor.black), for: .default) navigationController? I debugged the view and found that the UITabbar has implemented UIVisualEffectSubView and  Debug General debugging procedure. Configure the debugger settings. For a CMake project, select the desired CMake profile. If necessary, create or modify an existing run/debug configuration. Place breakpoints in your code. Click the Debug <configuration_name> button or use other options to start a debug session.

UINavigationBar.appearance().barTintColor = UIColor(hex:"YourColorcode")
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white,
                                                        NSFontAttributeName: UIFont(name:"AvenirNext-Medium", size:19.0)]

UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.white,
                                                     NSFontAttributeName: "YourFontName"], for: UIControlState.normal)

Troubleshooting Xcode, UINavigationBar Tint Not Working If you are trying to change the tint color of a navigation bar using the tintColor property and the color is not changing, it turns  The debugger will step to the next statement if it is not at a function when these commands are used. 3. Break on new worker (Ctrl+Shift+W) Breaks on the creation of a new web worker. 4. Exception control. Change exception behavior (Ctrl+Shift+E) opens options to change how the debugger reacts

#263: Changing the Color of the Status Bar, This work great until we put our view controller inside a navigation controller. Overriding the property then has no effect, as the system is  Debug Commands. Many debug commands are available for use with the ILE source . The debug commands and their parameters are entered on the debug command line displayed on the bottom of the Display Module Source and Evaluate Expression displays. These commands can be entered in uppercase, lowercase, or mixed case.

Navigation Controller · codepath/ios_guides Wiki · GitHub, The navigation controller is one example of a built-in UIKit container view controller. entering the class value since Xcode may not apply the change if you navigate out of tintColor = [UIColor colorWithRed:1.0 green:0.25 blue:0.25 Custom Views Quickstart · Debugging Apps · Designer Guides · Fixing  usb debugging s6 usb debugging not working usb debugging htc one m8 Fix USB Connection to PC lg g2 usb debugging. Category Education; Show more Show less.

Can't change UINavigation bar properties programmatically?, I'm trying to change the height/color programmatically, I have an outlet but nothing I Edit: note that using a navigationBar without a navigation controller isn't I can try that but I don't think that's the case, I can see the object when I debug and  Programatically change navigation bar title In order to change title of the navigation item(in ViewController) you have to set the title in viewDidLoad function of ViewController override func viewDidLoad() { super.viewDidLoad() self.navigationItem.title = "New title" } Following is an example output after this change Change status bar color

Comments
  • Please paste your code rather than screenshots. And how you added the bar buttons? UIBarButtonItem directly or with custom view? can you show us the code?
  • In main storyboard, this controller is embed with UINavigation controller? If yes then click on Navigation Controller and click on attribute inspector there is check of Show navigation Bar click on that. then your navigation bar is visible because in image your navigation bar is not visible.
  • @AnkitJayaswal I have add what you asked. The bar button was added via storyboard only, no code. I don't want the navigation bar visible - I have made it translucent in the code and want it that way. I only added that in case it affected the tintColors for the bar button items on a transparent navigation bar.
  • Ahh yes. This solved it for me. Thank you for the explaining when to set appearance() for it to work.
  • I dont need to change background color as navigation bar is transparent through my app. There is also no title or text in the navigation bar as the bar buttons are image assets. I added the navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.green] with a test title in the view controller, but that line also doesn't change the title color to green, just like my line of code (UINavigationBar.appearance().tintColor = .green ) won't change the tintColor of the barButtons. I'm looking for ways to debug why this isn't working.
  • Hello, thanks. I dont need to change the barTintColor because its clear or title because there is none. I just need to change the .tintColor but I can't get it to work. I am adding UINavigationBar.appearance().tintColor = .green directly to my viewDidLoad but it does not work and I need ways to figure out why this might be