Difference between VStack, HStack & ZStack in swiftUI
Автор: XCODE EXPLORER
Загружено: 2023-03-13
Просмотров: 90
Описание:
SwiftUI is a declarative framework for building user interfaces in iOS, macOS, watchOS, and tvOS. It provides a variety of layout containers for arranging views, including VStack, HStack, and ZStack.
VStack arranges views in a vertical stack, from top to bottom. You can think of it as a column of views that are centered horizontally by default. You can modify the alignment and spacing of the views in the VStack by using its modifiers. Here's an example of how to use VStack:
VStack {
Text("Hello")
Text("World")
}
This code creates a VStack with two Text views that are arranged vertically.
HStack arranges views in a horizontal stack, from left to right. You can think of it as a row of views that are centered vertically by default. You can modify the alignment and spacing of the views in the HStack by using its modifiers. Here's an example of how to use HStack:
HStack {
Text("Hello")
Text("World")
}
This code creates an HStack with two Text views that are arranged horizontally.
ZStack arranges views in a depth stack, with one view on top of another. You can think of it as a stack of cards where the top card obscures the cards below it. You can modify the alignment and position of the views in the ZStack by using its modifiers. Here's an example of how to use ZStack:
ZStack {
Color.blue
Text("Hello World")
}
This code creates a ZStack with a blue background color and a Text view on top of it.
In summary, VStack arranges views vertically, HStack arranges views horizontally, and ZStack arranges views in a depth stack. All three of these layout containers are essential for building complex user interfaces in SwiftUI.
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: