CosmicMind/Samples

how to change navbar with clear color

wilddylan opened this issue · 1 comments

how to change navbar with clear color
and set navigationItem tintcolor to white

To confirm, you want the background of the NavigationBar to be clear and the buttons to be white? If so, then you would need to set the background of the NavigationBar to clear, and that can be done through an extension for global settings and locally for isolated view controllers. For example:

class AppNavigationController: NavigationController {
    open override func prepare() {
        super.prepare()
        
        guard let v = navigationBar as? NavigationBar else {
            return
        }

        v.backgroundColor = .clear
        v.depthPreset = .none
    }
}

If you want to do it for a specific view controller, then you will need to use the helper navigationController? property in that view controller and set the background like so:

(navigationController?.navigationBar as NavigationBar)?.backgroundColor = .clear

To set the color of the buttons, you would need to do that for each button at the current moment. You can do that when you create the button, like so:

let button = IconButton(image: Icon.add, tintColor: .white)

navigationItem.leftViews = [button]

If you need further help, please use the Material Gitter channel. Thank you!