我在下面的代码中隐藏了状态栏,但是当用户决定记录屏幕时,我希望能够显示状态栏。我该怎么做?
Edit : I added the isCaptured property in a if statement but
when the screen recording is happening the status bar comes back
white and doesnt show the red bar for some reason. Anyone know why?
override var prefersStatusBarHidden: Bool {
if UIScreen.main.isCaptured == true {
print("show status bar")
return false
} else {
print("hide status bar")
return true
}
呼叫setNeedsStatusBarAppearanceUpdate
。这将导致再次调用prefersStatusBarHidden
,这次您返回false
。
只需在您的视图控制器上调用
setNeedsStatusBarAppearanceUpdate()
–这将迫使再次读取prefersStatusBarHidden
,此时 点可以返回一个不同的值。如果需要,请致电setNeedsStatusBarAppearanceUpdate()
实际上可以在 动画块,这会导致状态栏隐藏或显示在 平滑的方式。