Skip to content

Instantly share code, notes, and snippets.

@ole
Created June 12, 2022 15:19
Show Gist options
  • Save ole/e29440a1e8db90a36f64f630914722c0 to your computer and use it in GitHub Desktop.
Save ole/e29440a1e8db90a36f64f630914722c0 to your computer and use it in GitHub Desktop.
SwiftUI: How any `Layout`-conforming type becomes a container view when it's used with a `@ViewBuilder` closure.
// Excerpt from `SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-ios.swiftinterface`
// in Xcode 14.0b1
//
// This is how any `Layout`-conforming type becomes a container view
// when it's used with a `@ViewBuilder` closure.
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension SwiftUI.Layout {
@_alwaysEmitIntoClient public func callAsFunction<V>(@SwiftUI.ViewBuilder _ content: () -> V) -> some SwiftUI.View where V : SwiftUI.View {
return _VariadicView.Tree(
root: _LayoutRoot(self), content: content())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment