- 设置Info.list
添加属性:View controller-based status bar appearance 为YES
2.view后添加属性
.preferredColorScheme(ColorScheme.dark)
VStack {
Button(action: {}) {
Text(" Button")
}
HStack {
Text(" Slider").tint(.green)
Slider(value: $sliderValue, in: -100...100, step: 0.1)
}
}.preferredColorScheme(.dark)
ColorScheme.dark 字体白色
ColorScheme.light 字体黑色
链接地址:https://developer.apple.com/documentation/swiftui/view/preferredcolorscheme(_:)
网友评论