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("More Information!")},label:{
            Text("Click Here")
                .font(.title)
            Text("for more information")
                .font(.subheadline)
        })

Buttons using images

Buttons can also be created using images.

Button( action:{print("The Man the Myth the Legend")})
            {
            Image("steve")
            .renderingMode(.original)
            .clipShape(Circle())
            Text("Steve Jobs")
        }

Button using SF Symbols

You can also use SF Symbols for Buttons.

 HStack{
        Button( action:{print("Open Files")})
            {
            Image(systemName:"folder")
                Text("Files").font(.subheadline)
            }
           Button( action:{print("Todays' Schedule")})
            {
            Image(systemName:"calendar")
                Text("Calendar").font(.subheadline)
            }
        }