Reputation: 789
My highlighted images show different. Here is my situation.
[button setImage:"normal image" forState:UIControlStateNormal];
[button setImage:"hover image" forState:UIControlStateHighlighted];
[button setImage:"hover image" forState:UIControlStateSelected];
- (IBAction)buttonTouched:(id)sender {
UIButton *selectButton = sender;
if (_currentSelectedTabButton.tag == selectButton.tag) {
//TODO refresh view controller
return ;
}
_currentSelectedTabButton.selected = NO;
selectButton.selected = YES;
_currentSelectedTabButton = selectButton;
}
When a button is in selected state, highlighted images show incorrectly. Any ideas?
Upvotes: 2
Views: 1184
Reputation: 11
UIControlStateSelected | UIControlStateHighlighted is a state is independent of UIControlStateHighLighed
Upvotes: 0
Reputation: 335
This is because you are setting both the setImage:forControllState:UIControlStatesSelected and setHighlighted image and when you press button for first time its state being unselected the highlighted image is displayed and upon again pressing the button it shows the selected image since now the button is in selected state. (in short highlighted image will work in non-selected state of button only).
Upvotes: 2