How to Change Navigation Bar & Back Button Colour iOS 15

How to change navigation bar & back button colour iOS 15

These lines are totally pointless:

let navigationBar = UINavigationBar()
navigationBar.tintColor = .white
navigationBar.standardAppearance = appearance

You are creating a navigation bar, configuring it, and throwing it away. That does nothing for your app. Rewrite meaningfully:

    let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.backgroundColor = .red
let proxy = UINavigationBar.appearance()
proxy.tintColor = .white
proxy.standardAppearance = appearance
proxy.scrollEdgeAppearance = appearance

How to dynamically change navigation bar color on ios15?

In your VC you can try adjusting the view.backgroundColor

      UINavigationBar?.view.backgroundColor = MY_COLOR

Change current colour of NavigationBar in iOS15

the NavBar current-colour change based on user input while the app is running(after application(didFinisLaunching) has been called) is not working

You cannot change a navigation bar color while that navigation bar is showing by using the appearance proxy. The appearance proxy affects only future interface elements. You need to apply your UINavigationBarAppearance to the existing navigation bar directly:

self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = appearance

How to change back button color in nav bar?

Use Below To Change Back Button Color:

navigationController?.navigationBar.tintColor = UIColor.red

To Change Title Color of The Navigation Bar Use:

navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]

What is the right way to set back button arrow tint in ios 13

The new way of setting the back button color of the appearance (proxy) would be:

let appearance = UINavigationBarAppearance()

// Apply the configuration option of your choice
appearance.configureWithTransparentBackground()

// Create button appearance, with the custom color
let buttonAppearance = UIBarButtonItemAppearance(style: .plain)
buttonAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white]

// Apply button appearance
appearance.buttonAppearance = buttonAppearance

// Apply tint to the back arrow "chevron"
UINavigationBar.appearance().tintColor = UIColor.white

// Apply proxy
UINavigationBar.appearance().standardAppearance = appearance

// Perhaps you'd want to set these as well depending on your design:
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance


Related Topics



Leave a reply



Submit