如何在SwiftUI中创建具有特定暗模式颜色的局部变量。我试图避免将每个视图的配色方案指定为暗,以获得暗模式颜色。例如,在UIKit中,我可以使用以下代码获得暗模式颜色 let traitCollection = UITraitCollection(userInterfaceStyle: .dark)
let darkModeBlueUIColor= UIColor.systemBlue.resolvedColor(
我目前正在使用SwiftUI,因为我支持暗模式,所以我声明了一个颜色集,如果我的视图处于亮/暗模式,它必须符合该颜色集。当然,这需要对每个组件进行大量更改,现在我有很多包含此代码的视图 init() {
// Make Dividers the same color as the background to makebackgroundColor = UIColor(named: "background&
我有一个关于SwiftUI和Darkmode编程的小问题。我现在已经在swift编程4个月了,我想开始编程黑暗模式和灯光模式。.foregroundColor(Color(UIColor.systemGreen)) <- I usually do this
在光模式下,这是有效的,但如果我切换到暗模式<