Structure¶
LazyVStack¶
A view that arranges its children in a line that grows vertically, creating items only as needed.¶
Declaration¶
struct LazyVStack<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 LazyVStack that consists of a vertical row of text views. The stack aligns to the leading edge of the scroll view, and uses default spacing between the text views.
struct RowNumbersView: View {
var body: some View {
ScrollView {
LazyVStack(alignment: .leading) {
ForEach(1...100, id: \.self) { number in
Text("Row \(number)")
}
}
}
}
}

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