Text("Text")
.font(.subheadline)
.foregroundColor(.secondary)
ForEach([0, 1, 2, 3]) { index in
Text("line:\(index)")
}
if true {
Text("Hello true")
} else {
Text("Hello false")
}
A view that arranges its children in a vertical line.
VStack() {
Text("Hello World")
Text("Hello VStack")
}
A view that arranges its children in a horizontal line.
HStack() {
Text("Hello World")
Text("Hello HStack")
}
A view that overlays its children, aligning them in both axes.
ZStack() {
Text("Hello World")
Text("Hello ZStack")
}
A container that presents rows of data arranged in a single column.
List([0, 1, 2]) { index in
Text("line:\(index)")
}
An affordance for creating hierarchical view content.
Section {
Text("I am in a Section")
}
A control that toggles between on and off states.
struct FooView : View {
@State var toggle: Bool
var body: some View {
Toggle(isOn: $toggle) {
Text("$toggle")
}
}
}
A control used to perform semantic increment and decrement actions.
struct BarView : View {
@State var stepper: Int
var body: some View {
Stepper(value:$stepper, in: 1...10) {
Text("stepper")
}
}
}
A control that performs an action when triggered.
Button(action: { }) {
Image("foo")
Text("Button")
}