init(rows: [GridItem ], alignment: VerticalAlignment , spacing: CGFloat?, pinnedViews : PinnedScrollableViews , content: () -> Content)
Creates a grid that grows horizontally, given the provided properties.
Availability 有効性
Technology
struct LazyHGrid<Content> where Content : View
The grid is “lazy,” in that the grid view does not create items until they are needed.
In the following example, a Scroll
contains a Lazy
that consists of a horizontally-arranged grid of Text
views, aligned to the top of the scroll view. For each column in the grid, the top row shows a Unicode code point from the “Smileys” group, and the bottom shows its corresponding emoji.
var rows: [GridItem] =
Array(repeating: .init(.fixed(20)), count: 2)
ScrollView(.horizontal) {
LazyHGrid(rows: rows, alignment: .top) {
ForEach((0...79), id: \.self) {
let codepoint = $0 + 0x1f600
let codepointString = String(format: "%02X", codepoint)
Text("\(codepointString)")
.font(.footnote)
let emoji = String(Character(UnicodeScalar(codepoint)!))
Text("\(emoji)")
.font(.largeTitle)
}
}
}
init(rows: [GridItem ], alignment: VerticalAlignment , spacing: CGFloat?, pinnedViews : PinnedScrollableViews , content: () -> Content)
typealias Body
struct LazyVGrid
struct GridItem