Created
June 12, 2022 15:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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