我注意到iOS应用程序Things的iPhone应用程序中有一个状态栏,其中包含灰色内容(不是黑色或白色)。我在iPhone X上注意到了这一点。我的印象是,通过设置状态栏样式,您只能拥有带有黑色或白色内容的状态栏。
有关示例,请参见随附的屏幕截图。
他们将如何在其应用程序中实现这一目标?
编辑:我不是指状态栏的背景色,而是指状态栏中文本和图标的实际颜色。
好的,经过更多的挖掘,我在StackOverflow上找到了此注释。
正是我想要的。看起来它使用了某种私有API,因此在实际应用中实现它可能不是最明智的选择。
具体来说,下面找到适合我的代码。将此代码application(_:didFinishLaunchingWithOptions:)
放在您的AppDelegate中。
斯威夫特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")
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句