有没有办法让一个按钮在SwiftUI中运行多个功能?

有没有办法让一个按钮在SwiftUI中运行多个功能?,swift,button,swiftui,Swift,Button,Swiftui,我试图让一个按钮执行注销,并用一个按钮将布尔值更改为false。在SwiftUI中,有什么方法可以做到这一点吗 Button(action: GIDSignIn.sharedInstance()!.signOut, self.settings.settingsView.toggle()) { ZStack { Rectangle() .frame(width: 300, height: 50)

我试图让一个按钮执行注销,并用一个按钮将布尔值更改为false。在SwiftUI中,有什么方法可以做到这一点吗

Button(action: GIDSignIn.sharedInstance()!.signOut, self.settings.settingsView.toggle()) {
           ZStack {
               Rectangle()
                    .frame(width: 300, height: 50)
                    .cornerRadius(5)
                    .foregroundColor(Color(.systemGray))
               Text("Sign Out")
                    .foregroundColor(.primary)
                     .font(Font.system(size: 25))
                        }
                   }

您不必尝试将多个参数传递到
操作
中,只需执行闭包,并让它执行您想要的任意多个操作即可。看起来更像这样:

Button(action: {
    GIDSignIn.sharedInstance()!.signOut
    self.settings.settingsView.toggle()
}) {
    ZStack {
        Rectangle()
             .frame(width: 300, height: 50)
             .cornerRadius(5)
             .foregroundColor(Color(.systemGray))
        Text("Sign Out")
             .foregroundColor(.primary)
             .font(Font.system(size: 25))
     }
}

您不必尝试将多个参数传递到
操作
中,只需执行闭包,并让它执行您想要的任意多个操作即可。看起来更像这样:

Button(action: {
    GIDSignIn.sharedInstance()!.signOut
    self.settings.settingsView.toggle()
}) {
    ZStack {
        Rectangle()
             .frame(width: 300, height: 50)
             .cornerRadius(5)
             .foregroundColor(Color(.systemGray))
        Text("Sign Out")
             .foregroundColor(.primary)
             .font(Font.system(size: 25))
     }
}