The following code gotten from this post supposedly changes a button's color when it is pressed.
override var highlighted: Bool {
didSet {
if highlighted {
backgroundColor = UIColor.lightGrayColor()
} else {
backgroundColor = UIColor.whiteColor()
}
}
}
However, I was wondering what the variable "highlighted" would corrospond too?
If I programatically added a button to my view like this:
let exampleButton = UIButton()
self.view.addSubview(exampleButton)
//Set constraints,title-text,etc...
How would I get this to work with exampleButton
?