Skip to content

Instantly share code, notes, and snippets.

@wotjd
Created November 21, 2018 12:15
Show Gist options
  • Save wotjd/164ab8f91a05b573988713f53a8dcf6e to your computer and use it in GitHub Desktop.
Save wotjd/164ab8f91a05b573988713f53a8dcf6e to your computer and use it in GitHub Desktop.
import UIKit
class HighlightButton: UIButton {
@IBInspectable var highlightTintColor : UIColor?
private var prevTintColor : UIColor?
override var isHighlighted : Bool {
didSet {
if self.isHighlighted != oldValue {
self.prevTintColor = self.tintColor
self.tintColor = self.highlightTintColor
} else {
self.tintColor = self.prevTintColor
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment