Created
October 14, 2020 17:04
-
-
Save ananevam/215aabe642f91da4d6d068edfb5923d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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