I've got a UIButton that, when selected, shouldn't change state when being touched. The default behaviour is for it to be in UIControlStateHighlighted while being touched, and this is making me angry.
Suggestions?
I've got a UIButton that, when selected, shouldn't change state when being touched. The default behaviour is for it to be in UIControlStateHighlighted while being touched, and this is making me angry.
Suggestions?
Depending on what changes from the default to the highlighted state of the button, you can call a couple of methods to set them to what you need. So if the image changes you can do
[myButton setImage:[myButton imageForState:UIControlStateNormal] forState:UIControlStateHighlighted];
If the text changes you can do
[myButton setTitle:[myButton titleForState:UIControlStateNormal] forState:UIControlStateHighlighted];
other similar functions:
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state
- (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state
Hola,
OK here's an easy solution if this works for you, after a week of banging my head on this it finally occurred to me to just set highlighted=NO for the 1st line of the IBAction method for the TouchUpInside or TouchDown, or whatever works. For me it was fine on the TouchUpInside.
-(IBAction)selfDismiss:(id)sender {
self.btnImage.highlighted = NO;
NSLog(@"selfDismiss");
etc, etc, etc.
}