It is hard to change the appearance of UINavigationBar dynamically, so I made this lib to make the job easy.
- drag UINavigationBarExtension.swift file to project
The Extension includes lots of method that helps to change UINavigationBar's appearance dynamically:
func lt_setBackgroundColor(backgroundColor: UIColor)
func lt_setElementsAlpha(alpha: CGFloat)
func lt_setTranslationY(translationY: CGFloat)
func lt_reset()You can call the various setter wherever you want, like:
navigationController.navigationBar.lt_setBackgroundColor(.blueColor)And usually in viewWillDisappear, you should call this method to avoid any side effects:
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController.navigationBar.lt_reset()
}

