Reputation: 1202
When the user presses the bar button, it changes its color to grey. But the color of the bar button shouldn't change when the state is pressed
. I have the same problem like this question which never got solved and every answer is not working. There is no setUserInteractionEnabled
property. But disabling the whole bar button brings an alpha effect on the bar button wich I dont want to.
Any advice?
Upvotes: 2
Views: 3806
Reputation: 608
I had similar problem , i solved it by setting same image for both UIControlStateNormal and UIControlStateDisabled.Then disable the bar button.
UIImage *buttonImage = [UIImage imageNamed:@"ic_launcher.png"];
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setImage:buttonImage forState:UIControlStateNormal];
[aButton setImage:buttonImage forState:UIControlStateDisabled];
aButton.frame = CGRectMake(0.0,0.0,50,50);
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:aButton];
backButton.enabled = NO;
self.navigationItem.leftBarButtonItem = backButton;
Upvotes: 1
Reputation: 1194
You're right, there's no elegant solution. The best way to do this is to use a UIButton in the toolbar. Look at the EDIT part in this answer: How do I remove UIBarButtonItem glow programtically?
Upvotes: 4