I have a navigation bar that is set up and controlled completely with code. So it does not show up in IB. I have a button appear by "self.navigationitem.rightbarbutton = myButton;" An I make it go away by setting it equal to NIL. What I am wondering is how could I make it fade in and out?
相关问题
- UIBarButtonItem with separate portrait and landsca
- How to manually add a Back button to my Navigation
- Custom UIBarButtonItem with quartz
- I can't set UINavigationBar's barTintColor
- How i can use image in navigation bar title in swi
相关文章
- Navigation bar disappears when typing in UISearchC
- How to set different navigationbar color for diffe
- UINavigationBar with buttons as title.
- How to change the title of the UINavigationBar bac
- How can I change the background color of a UIBarBu
- Make UINavigationBar title editable
- UIBarButtonItem in middle of navbar?
- Change the color of a bar button in iOS 7
I found what worked best for me [self.navigationItem setRightBarButtonItem:myButton animated:YES]; And then [self.navigationItem setRightBarButtonItem:nil animated:YES]; To make it fade out.
Unfortunately there is no built in way to animate this for bar button items in a navigation bar. UIBarButtonItem is not a view or a control so it does not have animatable properties like alpha.
For bar button items in a UIToolbar, there is a way to animate. See this answer for details:
Is it possible to use Core Animation to fade out a UIBarButtonItem?
Swift version
fade in:
navigationItem.setRightBarButtonItem(myButton, animated: true)
fade out:
navigationItem.setRightBarButtonItem(nil, animated: true)