Lesson 4 Swift UI Button

Button with one label

Button’s perform actions and have Text components as their label.

Button( action:{print("Button Pressed!")},label:{Text("Submit")})

Button with multiple labels

Buttons can have more complex formatted labels.

 Button( action:{print("Multiple Labels")}, label:
        {
            VStack{
                Text("Click Here").font(.title)
                Text("For more information").font(.subheadline)
            }
        }
        )

Buttons using images

Buttons can also be created using images.

 Button(action:{print("Steve Jobs")})
        {
            VStack{
                Image("steve").renderingMode(.original)
                .clipShape(Circle())
                Text("Steve Jobs")
            }
        }

Button using SF Symbols

You can also use SF Symbols for Buttons.

  Button ( action:{print("using symbols")})
        {
            HStack{
                VStack{
                Image(systemName: "folder")
                Text("folder")}
                VStack{
                Image(systemName: "calendar")
                Text("calendar")
                    }
            }
        }