Is it possible to hide a UIToolbar with an animation?

*爱你&永不变心* 提交于 2019-12-23 19:08:36

问题


I know this code is available to UINavigationController only.

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

回答1:


An example using blocks. This will hide a toolbar at the top of an iPad screen.

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



回答2:


Here is the Code:

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

you can modify the toolBar 'y' origin.



来源:https://stackoverflow.com/questions/1830730/is-it-possible-to-hide-a-uitoolbar-with-an-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!