In a UIButton subclass:
- (void) setHighlighted:(BOOL)highlighted {
[super setHighlighted:highlighted];
if (highlighted) {
self.backgroundColor = [UIColor redColor];
}
else {
self.backgroundColor = [UIColor blueColor];
}
}
- (void)setSelected:(BOOL)selected {
[super setSelected:selected];
if (selected) {
self.backgroundColor = [UIColor greenColor]; //this happens
}
else {
self.backgroundColor = [UIColor blueColor];
}
}
I see the red color when the button is highlighted. But when I set button.selected = YES, I never see a green color. Why does setHighlighted work but setSelected doesn't?
I can set a breakpoint on the "this happens" line, and it happens. But the background color of the button doesn't change to green.