设置状态栏?

如何隐藏,显示或更改状态栏上的事件,如点击或价值变化?

我已经search了一个好的,但我所得到的是从一开始就改变了。 在这里,我需要dynamic地做到这一点。

那么你可以根据事件做以下事情:

//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 :以及。

UIApplication.sharedApplication()。setStatusBarHidden =真

您正在寻找var prefersStatusBarHidden: Bool { get }

在视图控制器中覆盖该函数。 使用funcdynamic更新状态栏的可见性setNeedsStatusBarAppearanceUpdate()

https://developer.apple.com/reference/uikit/uiviewcontroller/1621440-prefersstatusbarhidden