How can i disable the default Button click animation in SwiftUI and Swift 5? I tried to add .animation(.nil)
to the button, without any changes.
I know that you can do the following:
Button(action: {}) { Capsule() }
.buttonStyle(NoAnim())
struct NoAnim: ButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
}
Does anybody know a smarter way?
EDIT:
It has been quite a while, but i remember that in my use-case a Tap-Gesture with accessibility modifiers worked fine, I don't know why i haven't thought about it :).
However, if you use Mac-Catalyst (commented by @Laszlo) or need a Long-Press-Gesture to work as well (commented by @Womble), this might actually is the smartest way.
Also, here are 1, 2 articles about transactions (suggested by a comment from @TheCodingArtwork), maybe they help you to find a way to remove the Button animations.