2017-05-03 38 views
0

如何在點擊或更改值等事件上動態地隱藏,顯示或更改狀態欄?設置狀態欄?

我已經搜索了一口井,但我得到的是從this開始更改。在這裏,我需要動態地做到這一點。

+0

更新您的狀態欄的可見性對於手動配置狀態欄,請參閱本[文章](http://stackoverflow.com/q/38876249/6521116)。 –

回答

1

那麼這個你可以做以下基於事件:

//For hiding/unhiding: 
    func hideStatusBar(shouldHide:Bool){ 
    UIApplication.shared.isStatusBarHidden = shouldHide 
    } 

    //For Light Style: 
    func lightStatusBar(){ 
     UIApplication.shared.statusBarStyle = .lightContent 
    } 

    //For Standard Style: 
    func standardStatusBar(){ 
     UIApplication.shared.statusBarStyle = .default 

    } 

,或者你可以調整prefersStatusBarHidden:爲好。

+0

是的,很好,謝謝。 –

1

UIApplication.sharedApplication()。setStatusBarHidden =真

+0

你的代碼是swift2嗎? –

+1

是的,它在Swift 2中 – gargankit20