iosswiftbranch.ioios-sharesheet

iOS share sheet/extension not fading status bar


I have a share sheet/extension that, for some reason, is not fading the status bar (even though it fades the rest of the screen). I have included an image to demonstrate the issue. I simply want the entire screen to fade, including the status bar. In the past, I've had a similar issue with UIAlertControllers not fading the status bar.

image of status bar not being faded


Solution

  • Since I was seeing this as an app-wide issue, I started looking in my AppDelegate instead of the individual view controllers. I found a function, setStatusBarBackgroundColor(color: UIColor.white), called on app launch that appeared to be the cause.

    func setStatusBarBackgroundColor(color: UIColor) {
        guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }
        statusBar.backgroundColor = color
    }
    

    Frankly, I'm not sure why I had written this, but removing it appears to solve the issue entirely.