An UINavigationBar
extension which allows you to change its appearance dynamically in Swift.
There's this very interesting library called LTNavigationBar by Leo which has become very popular amongst iOS developers, but it has written in Objective-C.
I've chosen to write it in Swift
as it can be highly optimized by the compiler. The two demo projects are written in Swift
to demonstrate how it works.
The main purpose of this library is change the appearance of an UINavigationBar
dynamically ๐
The extension includes four methods that helps to change UINavigationBar
appearance dynamically:
func _setBackgroundColor(color: UIColor)
func setTranslationY(translation: CGFloat)
func setAlphaElements(alpha: CGFloat)
func reset()
It's recommended that in the viewWillDisappear
, you should call this method to avoid any side effects:
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.navigationBar.reset()
}
You can see the two demo projects for a better knowledge.