【问题标题】:Change foregroundcolor of statusbar更改状态栏的前景色
【发布时间】:2016-09-27 15:27:30
【问题描述】:

我在 swift 2.3 中使用此代码更改状态栏的前景色:

(application.value(forKey: "statusBar") as AnyObject).setValue(UIColor.red, forKey: "foregroundColor")

但是在 swift 3.0 的更新中,这部分不起作用,因为状态栏没有前台键。

有人可以在swift 3.0中更改状态栏的颜色吗?

谢谢。

【问题讨论】:

    标签: ios swift xcode swift3


    【解决方案1】:

    我用 AppDelegate 中的这一行解决了我的问题:

    let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
    statusBar.setValue(UIColor.red, forKey: "_foregroundColor")
    

    问候。

    【讨论】:

      猜你喜欢
      • 2015-09-26
      • 2019-11-20
      • 2016-10-16
      • 1970-01-01
      • 2015-10-09
      • 1970-01-01
      • 2019-11-05
      • 2012-02-21
      • 1970-01-01
      相关资源
      最近更新 更多