SwiftUI The series: Layout 101
- It’s responsible for display user interface.
- It’s must implement compute property
body, that’s responsible for display
viewon the user interface
The body property(View protocol) must return
one view . If you would like to display multiple view on user interface, you can use
Stack for group multiple views in one single view.
- It’s Display multiple views by vertical alignment
- By default, the views inside a
Vstackare aligned to the center
- It’s Display multiple views by Horizontal alignment
By default, the view in a horizontal stack are aligned to the center and positioned with standard space in between (usually 8 points)
The alignment options available for VStack and HStack views align the view in the opposite axis
- Vertical stack(VStack) can align the views horizontally
- Horizontal stack(HStack) can align the views vertically
- Vertical stack(VStack)
2. Horizontal stack(HStack)
The purpose of the
Group is to group multiple views that applying the same modifier
below, this is an example for creating views that using the same modifier.
As the example above, you can see that multiple views are using the same modifier that Causing redundant modifiers.
You can be using
Group to reduce redundant modifier
As the content above, that’s layout fundamental. The next episode, I’m telling about State on SwiftUI. Please to be continued.