Skip to content

Instantly share code, notes, and snippets.

@pogramos
Last active October 19, 2020 13:29
Show Gist options
  • Select an option

  • Save pogramos/5111b72612e79fb2dcc4fed10b0e20d0 to your computer and use it in GitHub Desktop.

Select an option

Save pogramos/5111b72612e79fb2dcc4fed10b0e20d0 to your computer and use it in GitHub Desktop.
CustomButton - Methods
private func apply(style: ButtonStyle) {
titleLabel?.font = style.font
setTitleColor(style.enabledTextColor, for: .normal)
setTitleColor(style.disabledTextColor, for: .disabled)
layer.borderWidth = style.borderWidth
layer.borderColor = style.borderColor.cgColor
layer.cornerRadius = style.cornerRadius
updateBackground()
}
private func updateBackground() {
if isEnabled {
backgroundColor = style.enabledBackgroundColor
} else {
backgroundColor = style.disabledBackgroundColor
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment