Reputation: 128
I have the code below where I am hiding the status bar but I want to be able to show the status bar when the user decides to record the screen. How would I be able to do that?
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
}
Upvotes: 0
Views: 464
Reputation: 2512
just call
setNeedsStatusBarAppearanceUpdate()
on your view controller – that will forceprefersStatusBarHidden
to be read again, at which point you can return a different value. If you want, your call tosetNeedsStatusBarAppearanceUpdate()
can actually be inside an animation block, which causes the status bar to hide or show in a smooth way.
Upvotes: 0
Reputation: 535890
Call setNeedsStatusBarAppearanceUpdate
. This will cause prefersStatusBarHidden
to be called again, and this time you return false
.
Upvotes: 1