Skip to content

Instantly share code, notes, and snippets.

@T1T4N
Created September 19, 2019 13:41
Show Gist options
  • Save T1T4N/5bfe7be2981af9bc6983fe1fec053aca to your computer and use it in GitHub Desktop.
Save T1T4N/5bfe7be2981af9bc6983fe1fec053aca to your computer and use it in GitHub Desktop.
A custom ButtonStyle that extends PlainButtonStyle functionality
struct CustomPlainButtonStyle: PrimitiveButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
// reuse the original button action
Button(action: configuration.trigger, label: {
// configure the button label to our needs
configuration.label
.frame(width: 200, height: 200)
.foregroundColor(Color.red)
.background(Color.green)
})
// This allows our button to retain
// default system behavior like e.g.
// the disabled gray out mask
.buttonStyle(PlainButtonStyle())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment