Skip to content

Instantly share code, notes, and snippets.

@krummler
Created April 17, 2020 10:10
Show Gist options
  • Save krummler/2a6ac98540ed64abffc4a5aee311401a to your computer and use it in GitHub Desktop.
Save krummler/2a6ac98540ed64abffc4a5aee311401a to your computer and use it in GitHub Desktop.
extension ButtonStyle {
func apply(to button: UIButton) {
button.backgroundColor = nil
button.titleLabel?.font = font
button.contentEdgeInsets = insets
button.setTitleColor(enabled.foreground, for: .normal)
button.setTitleColor(highlighted.foreground, for: .highlighted)
button.setTitleColor(disabled.foreground, for: .disabled)
button.setBackgroundImage(enabled.background, for: .normal)
button.setBackgroundImage(highlighted.background, for: .highlighted)
button.setBackgroundImage(disabled.background, for: .disabled)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment