首页 > 解决方案 > Changing the status bar color based on @State SwiftUI

问题描述

I am looking for a way to change the status bar color (time/service/battery) at the top of the screen based on a @State variable. I am using state to change different themes in my app. Some themes have a gray menu bar at the top and one has a black menu bar. When I switch to the black menu bar I can no longer see the status bar. Is there a way I can change that in my view based on the state? The app is written in SwiftUI and I am using a custom view modifier to change the styling based on state.

标签: swiftswiftui

解决方案


检查这个线程。或者,如果您觉得懒惰,您可以appearencesAssets.xcassets.preferredColorScheme(_:)


推荐阅读