简体   繁体   中英

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.

状态栏未褪色的图像

i think its better to tweak it only necessary UIViewControllers (when needed) by using,

override var preferredStatusBarStyle: UIStatusBarStyle {
    return UIStatusBarStyle.default  //dark content
}

or on the parenting UINavigationController , to avoid above bugs you have experienced.

Are you presenting a UIAlertController with animated: set to true? I'm not able to reproduce this issue using the buo.showShareSheet() method:

 let buo = BranchUniversalObject(canonicalIdentifier: "referrer/\(UUID().uuidString)")
        buo.title = "Test"
        buo.contentDescription = "Test"

        let lp: BranchLinkProperties = BranchLinkProperties()
        lp.feature = "referral"
        lp.addControlParam("user_id", withValue: UUID().uuidString)

        buo.showShareSheet(with: lp, andShareText: instructionString, from: self) { (params, success) in

        }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM