ContentView.html

  • defines structure of UI screen
  • uses view protocol (thus, it must use body property of type view)
  • body must return a single instance of view (example. string)

Modifiers

  • Modifiers are a function that that you apply to a view or the output of another modifier. For example, the modifier .largeTitle belongs to the Front class. In the example below, we have transformed our preceeding code to include the modifier.

var body: some View {
     t:String = "Hello Hommies"
     return t.font(
          .largeTitle)
          .bold()
          .foregroundColor(.red) // regular convention
}

Stacks

  • Vstack –> vertical
  • HStack –> horizontal
  • ZStack –> depth-based stack

Vstack and Hstack can be used simulateniously

Hstack also supports alignment. It specifies how views within the HStack should be aligned

  • bottom
  • center
  • firstTextBaseLine
  • lastTextBaseLi
  • top
HStack (alignment: .bottom) {

}

Now if you want the entire Hstack to be at the top of the screen, then you need a .frame()