I am building a quiz app. A question; 3 answers. The answers are in separate buttons.
I managed the change the color of the buttons when clicked. Eg from gray to green/red. But after the click the button goes back to gray.
Is there a way to keep the changed colors after the click, like a hyperlink in HTML?
This is the style code:
struct MyButtonStyle: ButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
.padding(20)
.foregroundColor(.white)
.background(configuration.isPressed ? Color.red : Color.gray)
.cornerRadius(10.0)