Happy New Year!
I want to hide status bar after calling UIImagePickerController on iOS 10.2. You know there are already several questions about it with some answers,
None of those answers worked for me on iOS 13. I had to set this flag on the presenting view controller before presenting the image picker:
viewController.modalPresentationCapturesStatusBarAppearance = YES;
[viewController presentViewController:picker animated:YES completion:nil];
The status bar can be permanently hidden with the following extension to UIImagePickerController
:
extension UIImagePickerController {
open override var childViewControllerForStatusBarHidden: UIViewController? {
return nil
}
open override var prefersStatusBarHidden: Bool {
return true
}
}
This is working for Swift 3, on iOS 10.
You are adding the delegate method method of UINavigationControllerDelegate
like below.
class PersonalInfoVC: UIViewController, UIImagePickerControllerDelegate , UINavigationControllerDelegate{
Adding the delegate and hide the status bar in it.
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool){
UIApplication.shared.isStatusBarHidden = true
}
The status bar can be hidden and show when presenting view controller UIImagePickerController swift 4+
picker.dismiss(animated: true, completion: {
if let statusBar = UIApplication.shared.value(forKey: "statusBar") as? UIView {
statusBar.isHidden = true
}
})
picker.dismiss(animated: true, completion: {
if let statusBar = UIApplication.shared.value(forKey: "statusBar") as? UIView {
statusBar.isHidden = false
}
})