xcode22
xcode22

Reputation: 128

How to show status bar in Swift when someone screen records inside my app?

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

Answers (2)

Harish
Harish

Reputation: 2512

just call setNeedsStatusBarAppearanceUpdate() on your view controller – that will force prefersStatusBarHidden to be read again, at which point you can return a different value. If you want, your call to setNeedsStatusBarAppearanceUpdate() can actually be inside an animation block, which causes the status bar to hide or show in a smooth way.

Upvotes: 0

matt
matt

Reputation: 535890

Call setNeedsStatusBarAppearanceUpdate. This will cause prefersStatusBarHidden to be called again, and this time you return false.

Upvotes: 1

Related Questions