Reputation: 2810
I have a UINaviationController
added through storyboard
with selected options like Hide Bars
On Tap
etc. I was wondering what is the best solution to react to navigationBar and toolbar shows/hides. I tried overriding UINavigationController
and methods like setNavigationBarHidden(_ hidden: Bool, animated: Bool)
, but this doesn't get called when you tap to hide. I think it's probably possible to observe some variable, but I'm not sure which one and if it will work.
Upvotes: 1
Views: 416
Reputation: 100543
You can try
var ob:NSKeyValueObservation?
override func viewDidLoad() {
super.viewDidLoad()
ob = self.navigationController?.observe(\.navigationBar.isHidden, options: [.new], changeHandler: { (nav, ob) in
print("ok")
})
}
Upvotes: 3