- 設(shè)置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(_:)