There must be a way to do this, but I can't find it. I have a button I have created programmatically:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(25, self.view.frame.size.height/4, 200, 350);
[button setTitle:@"Inbox" forState:UIControlStateNormal];
[button addTarget:self action:@selector(popViewController:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
All I want is for the button not to highlight or change in appearance in any way when it is touched. So far I have tried the following when creating the button:
[button setBackgroundImage:[UIImage imageNamed:nil] forState:UIControlStateSelected | UIControlStateHighlighted];
AND
[button setBackgroundImage:nil forState:UIControlStateSelected];
AND
[button setAdjustsImageWhenHighlighted:NO];
AND
button.showsTouchWhenHighlighted = NO;
Then in the button action I tried:
[sender setHighlighted:!sender.isHighlighted];
AND
[sender setSelected:!sender.isSelected];
None of these work.
You can just simply set adjustImageWhenHighlighted to No.
button.adjustsImageWhenHighlighted = NO;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With