更新时间:2023-01-27 17:30:55
在SwiftUI中,如果需要在某些子视图中使用light变体,则足以为其强制指定 .colorScheme
,如下所示
In SwiftUI if there is need to use light variant for some subview it is enough to force specify .colorScheme
for it, like below
颜色变体:
演示:
var body: some View {
VStack {
Rectangle().fill(Color("testColor"))
.frame(width: 100, height: 100)
.environment(\.colorScheme, .light) // << force light
}
.frame(width: 300, height: 300)
.background(Color("testColor")) // << system appearance
}