Structure¶
LazyHStack¶
A view that arranges its children in a line that grows horizontally, creating items only as needed.¶
Declaration¶
struct LazyHStack<Content> : View where Content : View
Overview¶
The stack is "lazy," in that the stack view doesn't create items until it needs to render them onscreen.
In the following example, a ScrollView contains a LazyHStack that consists of a horizontal row of text views. The stack aligns to the top of the scroll view and uses 10-point spacing between each text view.
struct ColumnNumberView: View {
var body: some View {
ScrollView(.horizontal) {
LazyHStack(alignment: .top, spacing: 10) {
ForEach(1...100, id: \.self) {
Text("Column \($0)")
}
}
}
}
}

Availability¶
iOS 14.0+
macOS 11.0+
tvOS 14.0+
watchOS 7.0+
Topics¶
Initializer¶
init(alignment:spacing:pinnedViews:content:) Creates a lazy horizontal stack view with the given spacing, vertical alignment, pinning behavior, and content.
Type Alias¶
Body The type of view representing the body of this view.