Home > Software design >  Changing Navigation Bar Color in Xcode
Changing Navigation Bar Color in Xcode

Time:02-02

I am building a Swift app and I am trying to change the color of the navigation bar. I'm trying to do it directly from Xcode without code on the main.storyboard.

I've tried changing several settings in the Xcode Attribute Inspector but nothing has worked. I've also searched StackOverFlow but all the answers I find are are changing it programatically.

Does anyone know how to change the color of it directly from the Attribute Inspector?

Thanks.

CodePudding user response:

Try it:

   if #available(iOS 13.0, *) {
                let appearance = UINavigationBarAppearance()
                appearance.configureWithOpaqueBackground()
                appearance.backgroundColor = UIColor(red: 21/255, green: 46/255, blue: 82/255, alpha: 1)
                appearance.titleTextAttributes = [.foregroundColor: UIColor.white, .font: UIFont(name: "Arial", size: 32)!]
                navigationController?.navigationBar.standardAppearance = appearance
                navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
                navigationController?.navigationBar.compactAppearance = appearance.copy()
}

CodePudding user response:

You can use

navigationBar.barTintColor = UIColor.whiteColor()

or you do this by Storyboard Like this.

enter image description here

CodePudding user response:

In the storyboard, change the background color like this. It will work.

  •  Tags:  
  • Related