navigation bar under status bar after video playback in landscape mode
Swift 3
In the presenting view controller, override the prefersStatusBarHidden
property to only hide the status bar if it's in landscape.
override var prefersStatusBarHidden: Bool {
return UIApplication.shared.statusBarOrientation.isLandscape
}
Then add an observer for when the device is rotated.
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(videoDidRotate), name: .UIDeviceOrientationDidChange, object: nil)
}
In the observer's method, call setNeedsStatusBarAppearanceUpdate
:
func videoDidRotate() {
self.setNeedsStatusBarAppearanceUpdate()
}
That should do it.
Status bar left white rectangle after rotate in landscape mode
SORRY!
I find the reason.
This is a custom view, that used for coloring statusbar.
Example of adding this view.
let statusBarView = UIView(frame: UIApplication.shared.statusBarFrame)
let statusBarColor = UIColor(r: 240, g: 243, b: 245)
statusBarView.backgroundColor = statusBarColor
view.addSubview(statusBarView)
Thank you everyone!
iOS Status Bar remains in landscape after full screen video
Ok, I figured it out.
I added a button to the view controller that I present as a modal view with my video and that button triggers the following:
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self dismissModalViewControllerAnimated:YES];
When the button is triggered, the status bar is forced to portrait and the app returns to normal state. I removed the action for the "Done" button when I'm in fullscreen.
Hope this helps someone
Status Bar Hides The Navigation Bar
try like this
// create a new class of type UIViewController
class BaseViewController : UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.videoExitFullScreen()
}
func videoExitFullScreen (){
navBar.frame.origin = CGPoint(x: 0, y: 20)
}
}
// replace UIViewController to BaseViewController
class ViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
}
Navigation bar hidden, move remaining view under status bar
- Click drop-down arrow on Top, Select Current view option. - It will Start from Status bar
Related Topics
Swift - Using Replacerange() to Change Certain Occurrences in a String
Webkit Overflow Scrolling Touch CSS Bug on iPad
Email Validation on Textfield in iOS
Trouble with Autolayout on Uitableviewcell
Determine If iOS Device Is 32- or 64-Bit
Convert Swiftui View to PDF on iOS
How to Programmatically Find Swift's Version
Reverse an Audio File Swift/Objective-C
iOS Safari Memory Usage with "-Webkit-Transform"
Sort Array of Dictionaries by Key Value
Xcode 8.3/Xcode 9.0 Refresh Provisioning Profile Devices
Swift: How to Get Substring from Start to Last Index of Character
Upload Image to the PHP Server from iOS
How to Use Static Cells in Uitableview Without Using Storyboards