What is the built in method which can be used to hide and show toolsbars. specifying a rate or speed of the animation?
Asked
Active
Viewed 5,342 times
2 Answers
8
Look at this question, and do something like:
[UIView animateWithDuration:2.0
animations:^{
[self.navigationController setToolbarHidden:YES animated:YES];
}
completion:^(BOOL finished){
// whatever
}];
-
Great, what is UIView here? self will by viewController. – some_id Feb 28 '11 at 23:08
-
UIView is the http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html. So animateWithDuration is a static method for the class UIView. – ThomasRS Feb 28 '11 at 23:13
-
1Note for future viewers: If you use the toolbar's own "animated:YES" method inside the `animateWithDuration` call, the the animation will use the standard timing. Instead, substitute `self.navigationController.toolbarHidden = YES;` and the animation will obey the duration (and options if you use that method) that you set. – Wienke Aug 09 '12 at 16:12
2
Toolbar's just a view—add an IBOutlet in your controller, then use UIView's (class methods) block animation methods, such as animateWithDuration:delay:options:animations:completion:
or animateWithDuration:animations:
. In the animation block, just move the view.frame.size.origin.y to a different location, or set its opacity to zero. the methods also allow you to specify the time period over which the animation will occur. Once complete (there's a delegate callback in the first method), you can then ask your main view to get taller by using the same methods to change the view.frame.size.origin.y of your main view.

FeifanZ
- 16,250
- 7
- 45
- 84
-
Great, I want to fade it in and out over a certain time frame. how is this method called on an object. is the object passed in somewhere or is it called on the object directly? – some_id Feb 28 '11 at 22:42
-
The method is actually a UIView class method that simply tells the system you want to begin animation. There's a corresponding method that actually "ends" the animation block. Within that block of two methods, you can do whatever you want, such as myToolbar.alpha = 0.0; – FeifanZ Mar 01 '11 at 11:24
-
In the method you can set the duration of the animation, and by the end of that duration the opacity of the toolbar will be 0. Read the docs for the exact details. – FeifanZ Mar 01 '11 at 11:25