Reputation: 945
I'm using UINavigationController, works fine, problem occurs when I play a video inside a Webview & change device orientation, then navigation bar of controller overlaps with status bar, screenshot attached. I've seen these solutions ios 11 custom navbar goes under status bar
, ios 11 navigation bar overlap status bar
, but those solutions apply while not using navigation controller since I can't change properties of navigationController's navigation bar, any suggestions ?
Upvotes: 1
Views: 1247
Reputation: 945
So I was able to solve this issue, here is the solution that worked for me
open override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(updateStatusBar), name: Notification.Name.UIWindowDidBecomeKey, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateStatusBar), name: Notification.Name.UIDeviceOrientationDidChange, object: nil)
}
and
@objc func updateStatusBar() {
UIApplication.shared.isStatusBarHidden = UIApplication.shared.statusBarOrientation.isLandscape
setNeedsStatusBarAppearanceUpdate()
}
Upvotes: 2