How to hide the status bar programmatically in iOS 7?

后端 未结 12 1746
眼角桃花
眼角桃花 2020-12-05 17:00

In ios7, how can I hide the statusbar programmatically? I am using XCode 4.6.1 (ios6.1) and I want to implement this in XCode itself.

12条回答
  •  北海茫月
    2020-12-05 17:43

    Swift 4.1

    step1. Set View controller-based status bar appearance in your info.plist to YES

    step2. Type some code in your UIViewController, status bar will hide when you present the UIViewController.

    private var statusBarIsHidden = false
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    
        statusBarIsHidden = true
        setNeedsStatusBarAppearanceUpdate()
    }
    override var prefersStatusBarHidden: Bool {
        return statusBarStatus
    }
    

提交回复
热议问题