Contents

callAsFunction(_:)

Combines the specified views into a single composite view using the layout algorithms of the custom layout container.

Declaration

func callAsFunction<V>(@ViewBuilder _ content: () -> V) -> some View where V : View

Parameters

  • content:

    A Viewbuilder that contains the views to lay out.

Return Value

A composite view that combines all the input views.

Discussion

Don’t call this method directly. SwiftUI calls it when you instantiate a custom layout that conforms to the Layout protocol:

BasicVStack { // Implicitly calls callAsFunction.
    Text("A View")
    Text("Another View")
}

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