I am trying to change color of textfield with below code but it is not working. It takes color as white if the it is light theme and for dark theme automatically takes black color. I want to keep it always black.
var body: some View {
TextField(self.textFieldTitle ?? "", text: self.$textFieldInput, onEditingChanged: { editing in self.dosomeCode()}, onCommit: { self.someCode()})
.background(Color.green)
.foregroundColor(Color.white)
}
I want to keep it always black.
Use .black color instead
TextField(self.textFieldTitle ?? "", text: self.$textFieldInput, onEditingChanged: { editing in self.dosomeCode()}, onCommit: { self.someCode()})
.background(Color.green)
.foregroundColor(Color.black) // << here !!
Tested with Xcode 13.2 / iOS 15.2