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

為{幸葍}努か 提交于 2019-11-29 14:51: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.

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
}
Akshay Mirgal

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
    }
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!