Using Swift5.3.2, iOS14.4.1, Xcode12.4,
I try to make a custom-Color change when switching from light to dark mode in SwiftUI.
Here is my code:
import SwiftUI
struct MyTestView : View {
var body: some View{
VStack {
Rectangle()
.foregroundColor(Color("loginBG"))
}
}
}
The MyTestView
is called right at the beginning of my App lifecycle (real simple example):
import SwiftUI
@main
struct myApp: App {
var body: some Scene {
WindowGroup {
MyTestView()
}
}
}
Here is my Color definition of loginBG
:
Here is the video showing that the Rectangle does unfortunately not change color - why ?????
(from the status-Bar color-switch you can see that I indeed changed from light-mode to dark-mode and back. But no Rectangle-Color change at all)