Structure¶
TupleView¶
A View created from a swift tuple of View values.¶
Declaration¶
@frozen struct TupleView<T> : View
Overview¶
TupleView is mainly used with ViewBuilder, so you don't really need to worry about it unless you're making your own view builders.
In the example below, we use this type to create a new kind of View that only displays the first view it is passed. The second view is ignored. Kind of useless? Yes. Instructive? You tell me.
struct ContentView: View {
var body: some View {
FirstView {
Text("I am first 🥇")
Text("Hey stop ignoring me ☹️")
}
}
}
struct FirstView<First: View, Second: View>: View {
let first: First
init(@ViewBuilder content: () -> TupleView<(First, Second)>) {
let views = content().value
first = views.0
}
var body: some View {
first
}
}

Availability¶
iOS 13.0+
macOS 10.15+
tvOS 13.0+
watchOS 6.0+
Topics¶
Initializer¶
init(_:) Creates a tuple view.
Type Alias¶
Body The type of view representing the body of this view.