Instance Method インスタンスメソッド

callAsFunction()

Dismisses the view if it is currently presented.

Declaration 宣言

func callAsFunction()

Discussion 議論

Don’t call this method directly. SwiftUI calls it for you when you call the DismissAction structure that you get from the Environment:


private struct SheetContents: View {
    @Environment(\.dismiss) private var dismiss


    var body: some View {
        Button("Done") {
            dismiss() // Implicitly calls dismiss.callAsFunction()
        }
    }
}

For information about how Swift uses the callAsFunction() method to simplify call site syntax, see Methods with Special Names in The Swift Programming Language.