I have 2 custom button styles and I want to change the style when I tap the button. I tried this way:
Button(action: {
self.pressed.toggle()
})
{
Text("Button")
}.buttonStyle(pressed ? style1() : style2())
But it is not working, it is giving me an error from the VStack that it belongs to:
Unable to infer complex closure return type; add explicit type to disambiguate
If I do something like:
.buttonStyle(style1())
Or
.buttonStyle(style2())
Then the error goes away, so it's not from style1() or style2().