Customizing Navigation Bar Appreance using SwiftUI

If you are having trouble trying to customize the navigation appearance like I have been.

You can use the following code, I have been placing my code in its own function and calling from the delegate function application(application:launchOptions:).

func customNavigationAppearance() {
     let appearance = UINavigationBarAppearance()

     appearance.backgroundColor = .black
     appearance.titleTextAttributes = [ .foregroundColor: UIColor.white ]
     appearance.largeTitleTextAttributes = [ .foregroundColor: UIColor.white ]

     UINavigationBar.appearance().tintColor = .white
     UINavigationBar.appearance().backgroundColor = .black
     UINavigationBar.appearance().standardAppearance = appearance
     UINavigationBar.appearance().scrollEdgeAppearance = appearance

You can create another appearance for when your navigation is in a scrolled state by setting standardAppearance to an object with your appearance preferences.

Colour appropriately.

Jun 11th, 2020 • Posted in Apple, iOS, SwiftUI
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>