【问题标题】:Status bar blinked when hide and show status bar隐藏和显示状态栏时状态栏闪烁
【发布时间】:2018-02-12 08:48:16
【问题描述】:

在 iOS 11 中,我遇到了状态栏显示/隐藏的问题。 但它只是在我更改颜色状态栏时发生

UIApplication.shared.statusBarStyle = .lightContent
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
if statusBar.responds(to: #selector(setter: UIView.backgroundColor)) {
    statusBar.backgroundColor = UIColor.black
}

我有两个屏幕。屏幕 1 显示黑色状态栏,屏幕 2 隐藏黑色状态栏。返回屏幕 1 时,状态栏会闪烁。

我将我的示例上传到 Github: https://github.com/phungtai/StatusBar.git

注意:
- 仅限 iOS 11.xx.xx
- 更改颜色状态栏时发生,保持默认不会发生。 https://media.giphy.com/media/l3dj1EXWwic3oP6KY/giphy.gif

【问题讨论】:

标签: ios swift statusbar


【解决方案1】:

我用新的解决方案更改状态栏颜色并解决了错误

let statusBar: UIView = UIView()

// In didFinishLaunchingWithOptions AppDelegate

statusBar.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 20)
        statusBarView.backgroundColor = UIColor.black
        UIApplication.shared.statusBarStyle = .lightContent
        let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
        window?.rootViewController?.view.insertSubview(statusBar, aboveSubview: statusBar)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-29
    • 1970-01-01
    • 2021-06-26
    • 1970-01-01
    • 1970-01-01
    • 2014-10-14
    • 2012-01-06
    • 1970-01-01
    相关资源
    最近更新 更多