Skip to content

Instantly share code, notes, and snippets.

@fabiogiolito
Created December 5, 2018 13:38
Show Gist options
  • Save fabiogiolito/91c11bf870364e9de904eeaeb0db537d to your computer and use it in GitHub Desktop.
Save fabiogiolito/91c11bf870364e9de904eeaeb0db537d to your computer and use it in GitHub Desktop.
class StyledButton: UIButton {
...
convenience init(
text: String? = nil,
image: UIImage? = nil,
styles: [ButtonStyle] = []
){
self.init(type: .system)
self.setTitle(text, for: .normal)
self.setImage(image, for: .normal)
self.layer.borderWidth = 1
self.layer.borderWidth = 4
self.setContentHuggingPriority(.defaultHigh, for: .vertical)
self.contentEdgeInsets = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
self.styles = styles
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment