swift - 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.
解决方案
检查这个线程。或者,如果您觉得懒惰,您可以appearences
在Assets.xcassets
.preferredColorScheme(_:)
推荐阅读
- c# - Entity Framework 6 自动迁移在生产服务器上定期重建表
- google-apps-script - 如何运行仅在 Google Apps 脚本中的值不为空时才执行某些操作的函数?
- css - App.jsx:11 未捕获的类型错误:无法读取未定义的属性“TodoComponent”
- angularjs - Puppeteer 访问角度控制器功能
- node.js - Node/Sequelize:加载所有模型
- visual-studio-2015 - Wix 工具集:如何在 wix 项目中引用自定义 wix 扩展
- sql - Oracle 数据库模式名称
- php - 如果打开时出现这样的 php 文件,如何克服?
- css - R:在 Rmd 中更改整个数据表的宽度
- ibeacon - 如何在 iOS、Ibeacon 上创建动态 CLBeaconRegion