简体   繁体   English

对比状态栏文本/图标 Colors (iOS13/Xcode11)

[英]Contrasting Status Bar Text/Icon Colors (iOS13/Xcode11)

I'm seeing a lot of conflicting sources, and their solutions are always involving deprecated keywords that no longer work either in iOS 13, XCode 11, or both.我看到很多相互矛盾的来源,他们的解决方案总是涉及已弃用的关键字,这些关键字在 iOS 13、XCode 11 或两者中都不再起作用。 My simulated iPhone is running iOS 13.6 and my XCode is version 11.6.我的模拟 iPhone 运行的是 iOS 13.6,我的 XCode 是 11.6 版。

I've made it so that the navigation bar title and buttons take on a contrasting color (white or black) to the background color.我已经做到了,导航栏标题和按钮与背景颜色形成对比色(白色或黑色)。 I'd like to make the status bar text and symbols (the wifi, clock, battery icon, etc.) take on the same appearance depending on the background.我想让状态栏文本和符号(wifi、时钟、电池图标等)根据背景呈现相同的外观。 Is there a way to do this?有没有办法做到这一点? 在此处输入图像描述

In your view controller (aka hosting controller for SwiftUI), override the preferredStatusBarStyle variable.在您看来 controller(又名托管 controller 用于preferredStatusBarStyle ),覆盖 PreferredStatusBarStyle 变量。 For example:例如:

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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