是否可以使用动画隐藏UIToolbar?

时间:2009-12-02 04:54:16

标签: iphone-sdk-3.0 uitoolbar

我知道此代码仅供UINavigationController使用。

[self.navigationController setNavigationBarHidden:YES animated:YES];

2 个答案:

答案 0 :(得分:9)

使用块的示例。这将隐藏iPad屏幕顶部的工具栏。

[UIView animateWithDuration:.7 
                 animations:^(void)
                 {
                     CGRect toolbarFrame = self.toolbar.frame;
                     toolbarFrame.origin.y = -44; // moves iPad Toolbar off screen
                     self.toolbar.frame = toolbarFrame;
                 } 
                 completion:^(BOOL finished)
                 {
                     self.toolbar.hidden = YES;
                 }];

答案 1 :(得分:1)

以下是代码:

[UIView beginAnimations:@"hideView" context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:toolBar cache:YES];
toolbarFrame.origin.y = 380;
toolBar.frame = toolbarFrame;
[UIView commitAnimations];

你可以修改toolBar'y'的来源。