Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set alpha value of NavigationItem

I try to set the alpha value of a navigationItem to animate the rightBarbutton, but I can´t get it change the value. Any suggestions?

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
                                  initWithTitle:@"Avbryt" 
                                  style:UIBarButtonItemStyleBordered
                                  target:self action:@selector(cancelEditing)] autorelease];

self.navigationItem.rightBarButtonItem.customView.alpha = 0.5;
like image 249
Silversnail Avatar asked Aug 10 '11 09:08

Silversnail


1 Answers

In your code you are trying to set alpha for the rightBarButtonItem's customView, but you your rightBarButton item doesn't contain any custom view. Isn't it?

UIBarButtonItem item is a direct subclass of UIBarItem which in turn is a subclass of NSObject. So, it is not possible to set its alpha directly. You are correct about setting alpha for the customView, but you have missed to add the customView itself ;-)

like image 54
EmptyStack Avatar answered Sep 22 '22 15:09

EmptyStack