Reputation: 10226
I have a struct like this. How do I call SwiftUIButton with action?
struct SwiftUIButton: View{
let action: () -> ()
var body: some View{
Button(action: action){Text("Tap me")}
}
}
Upvotes: 1
Views: 154
Reputation: 257543
Here it is
SwiftUIButton {
// do anything here
print(">> button tapped")
}
which is the same (but short variant) of
SwiftUIButton(action: {
// do anything here
print(">> button tapped")
})
Upvotes: 1