SwiftUI navigation bar button color code example
Example 1: swift change navigation bar color
navigationController?.navigationBar.barTintColor = UIColor.green
navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.orange]
tabBarController?.tabBar.barTintColor = UIColor.brown
tabBarController?.tabBar.tintColor = UIColor.yellow
Example 2: add navigation bar button swiftui
.navigationBarItems(
leading: Button(action: {
}, label: { Text("Button") }),
trailing: Button(action: {
}, label: { Image("Icon") })
)
Example 3: navigation title bar color swftui
init() {
let navBarAppearance = UINavigationBar.appearance()
navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
}