Swift 3.0 - how to hide status bar after calling UIImagePickerController?

后端 未结 4 1957
太阳男子
太阳男子 2020-12-21 04:57

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,

相关标签:
4条回答
  • 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];

    0 讨论(0)
  • 2020-12-21 05:41

    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.

    0 讨论(0)
  • 2020-12-21 05:50

    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
    }
    
    0 讨论(0)
  • 2020-12-21 05:52

    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
        }
    })
    
    0 讨论(0)
提交回复
热议问题