能否使用动画隐藏UIToolbar?

3

我知道这段代码只适用于 UINavigationController

[self.navigationController setNavigationBarHidden:YES animated:YES];
2个回答

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

以下是程式碼:

[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];

你可以修改工具栏的 'y' 坐标。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接