The button text does not change colors properly when switching between light and dark mode. In light mode it shows up as a black button with white text. in dark mode it just shows a white button with assumably white text. I'm looking to apply a style that adapts automatically in light/dark mode.
struct Primary: View {
var body: some View {
Button("hello") {}
.buttonStyle(.borderedProminent)
.tint(.primary)
// .disabled(true) // optional
}
}
I've tried splitting the Button init so i can modify the text directly but with no success. It shows up correctly when adding the .disabled modifier.
Clarification: I am looking for a way to inverse the colors of the button in dark mode while preserving the .disabled color scheme of primary. I would prefer to avoid a bunch of if statements if possible.
I've added text on the image for the bottom left. This is the result i'm looking to achieve for the button when going through light/dark, disabled/enabled. link to image

You can directly set the text color using
.foregroundColor()modifier within theButtoninitializer. Using.primaryas the color ensures it automatically adjusts based on the appearance mode. Here's an example: