Skip to content

Instantly share code, notes, and snippets.

@ananevam
Created October 14, 2020 17:04
Show Gist options
  • Save ananevam/215aabe642f91da4d6d068edfb5923d9 to your computer and use it in GitHub Desktop.
Save ananevam/215aabe642f91da4d6d068edfb5923d9 to your computer and use it in GitHub Desktop.
@IBDesignable
class IconView: UIImageView {
override func layoutSubviews() {
super.layoutSubviews()
updateView()
}
@IBInspectable var iconColor: UIColor = UIColor.clear {
didSet {
updateView()
}
}
func updateView() {
let templateImage = self.image?.withRenderingMode(.alwaysTemplate)
self.image = templateImage
self.tintColor = iconColor
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment