【问题标题】:Custom iOS Status Bar Color自定义 iOS 状态栏颜色
【发布时间】:2018-02-14 23:42:20
【问题描述】:

我注意到 iOS 应用程序 Things 在其 iPhone 应用程序中有一个带有灰色内容(不是黑色或白色)的状态栏。我在 iPhone X 上注意到了这一点。我的印象是,您只能通过设置状态栏样式来获得带有黑色或白色内容的状态栏。

有关示例,请参见随附的屏幕截图。

他们如何在他们的应用中实现这一点?

编辑:我不是指状态栏的背景颜色,我是指状态栏中文字和图标的实际颜色。

【问题讨论】:

    标签: ios iphone swift


    【解决方案1】:

    好的,经过一番挖掘,我在 StackOverflow 上找到了this comment。

    它完全符合我的要求。看起来它使用了某种私有 API,所以在实际应用中实现可能不是最明智的做法。

    特别适合我的代码在下面找到。将此代码放入您的 AppDelegate 中的application(_:didFinishLaunchingWithOptions:)。

    斯威夫特 4

    if application.responds(to: Selector(("statusBar"))),
        let statusBar = application.value(forKey: "statusBar") as? UIView,
        statusBar.responds(to: #selector(getter: CATextLayer.foregroundColor)) {
            statusBar.setValue(UIColor.gray, forKey: "foregroundColor")
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多