开发者

Set alpha value of NavigationItem

开发者 https://www.devze.com 2023-03-27 04:20 出处:网络
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?

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.c开发者_如何学JAVAustomView.alpha = 0.5;


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 ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消