Home > Software design >  Navigation bar and tab bar turned black on iOS15 Xcode 13
Navigation bar and tab bar turned black on iOS15 Xcode 13

Time:09-24

Today I just updated my Xcode to version 13 and found that all the navigation bars and the tab bars of my project turned black, I didn't change any settings, my project was working fine on Xcode 12, and I have toggled it to light mode, I couldn't find a way to recover the appearances to the old ones.enter image description here

enter image description here

CodePudding user response:

Apply the following code to update the appearance of the navigation bar. This can be done in AppDelegate if you wish for it to be the appearance throughout the app.

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: .black]
appearance.backgroundColor = .white
// Default portrait view
UINavigationBar.appearance().standardAppearance = appearance
// There are other appearances you could apply it to as well...
// UINavigationBar.appearance().scrollEdgeAppearance = appearance
// UINavigationBar.appearance().compactAppearance = appearance

CodePudding user response:

Make like this:

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .red
appearance.titleTextAttributes = [.font: 
UIFont.boldSystemFont(ofSize: 20.0),
                              .foregroundColor: UIColor.white]

// Customizing our navigation bar
navigationController?.navigationBar.tintColor = .white
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance

I wrote a new article talking about it.

https://medium.com/@eduardosanti/uinavigationbar-is-black-on-ios-15-44e7852ea6f7

  • Related