I'd like to set the color of a Text view inside a Button view based on whether the button is enabled or disabled. What is the smartest way to do this and also to get the system default colors for enabled/disabled colors, because I don't want to set any gray shade, I'd like to set the "normal" gray shade.
Actually, adding .buttonStyle(.plain) to the button just did what I was looking for. Now, the button automatically gets a gray color if it's disabled.
Here is how to do it in SwiftUI 2.0
Button("PressME", action: {self.playerAttemptCount += 1
}).buttonStyle(PlainButtonStyle())
This way, the button automatically gets a gray color if it is disabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With