Skip to content

Instantly share code, notes, and snippets.

@johnsusek
Created June 6, 2019 00:21
Show Gist options
  • Select an option

  • Save johnsusek/b8908215fa21701efd0fcbcf2edd111a to your computer and use it in GitHub Desktop.

Select an option

Save johnsusek/b8908215fa21701efd0fcbcf2edd111a to your computer and use it in GitHub Desktop.
// #1 - Default button
Button(action: {}) {
Text("Example 1")
}
// #2 - Give it some padding, a background, and rounded corners
Button(action: {}) {
Text("Example 2").color(.white)
}
.padding(.all)
.background(Color.blue, cornerRadius: 7)
// #3 - Add spacers to push button to edges
Button(action: {}) {
HStack {
Spacer()
Text("Example 3").color(.white)
Spacer()
}
}
.padding(.all)
.background(Color.blue, cornerRadius: 7)
// #4 - Embed in a vstack with padding so it doesn't go to edges
VStack {
Button(action: {}) {
HStack {
Spacer()
Text("Example 4").color(.white)
Spacer()
}
}
.padding(.all)
.background(Color.blue, cornerRadius: 7)
}.padding([.leading, .trailing])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment