init(alignment: VerticalAlignment , spacing: CGFloat?, content: () -> Content)
Creates a horizontal stack with the given spacing and vertical alignment.
Availability 有効性
Technology
@frozen struct HStack<Content> where Content : View
Unlike Lazy
, which only renders the views when your app needs to display them onscreen, an HStack
renders the views all at once, regardless of whether they are on- or offscreen. Use the regular HStack
when you have a small number of child views or don’t want the delayed rendering behavior of the “lazy” version.
The following example shows a simple horizontal stack of five text views:
var body: some View {
HStack(
alignment: .top,
spacing: 10
) {
ForEach(
1...5,
id: \.self
) {
Text("Item \($0)")
}
}
}
init(alignment: VerticalAlignment , spacing: CGFloat?, content: () -> Content)
typealias Body
struct VStack
struct ZStack