Please help. I can’t figure out how to change a button’s modifiers when it is pressed. I want some kind of change on the button to indicate that it is off or on (different foreground or background color perhaps). I looked up the toggle command but if I use that as a button then I don’t know how to assign an action to it like a real button. I hope that makes sense. I’m obviously a beginner.
This code does not work but it gives an idea of what I am trying to do.
struct PESelect: View {
@State private var isOn = false
var body: some View {
Button(action: {
if isOn == false { foregroundColor(Color.red)}})
{Text("no sweats")
.frame(maxWidth: .infinity)
}
.buttonStyle(PlainButtonStyle())
}
}