我在标签栏应用程序工作。如何隐藏特定视图中的tabbar?
在所有视图tabbar中携带。好。
但在特定的一个视图中,我不想显示我的tabbar。
当我把我的视图推到下一个视图时,标签栏也带到了这个视图。
当我试图隐藏它时,它显示了该视图的空白区域。
做什么..提前thnaks
我在标签栏应用程序工作。如何隐藏特定视图中的tabbar?
在所有视图tabbar中携带。好。
但在特定的一个视图中,我不想显示我的tabbar。
当我把我的视图推到下一个视图时,标签栏也带到了这个视图。
当我试图隐藏它时,它显示了该视图的空白区域。
做什么..提前thnaks
您可以将视图添加到主窗口,这将是在标签栏:
[[myApp appDelegate].window addSubview:myView];
UITabBar是一个顶级视图,这意味着几乎所有的观点都在它的下面。即使UINavigationController在tabBar的下方也是如此。
可以隐藏的TabBar这样的:
- (void)hideTabBar:(UITabBarController *)tabbarcontroller withInterval:(NSTimeInterval)delay {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:delay];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+50, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+50)];
}
}
[UIView commitAnimations];
}
然后再显示它回到这样的:
- (void)showTabBar:(UITabBarController *)tabbarcontroller withInterval:(NSTimeInterval)delay {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:delay];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-50, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-50)];
}
}
[UIView commitAnimations];
}
UITabBar是高度50像素的默认。所以你只需要为框架设置新的高度并为其设置动画。
尝试....
MyViewController *myController = [[MyViewController alloc] init];
//hide tabbar
myController.hidesBottomBarWhenPushed = YES;
//add it to stack.
[[self navigationController] pushViewController:myController animated:YES];
它的工作原理..谢谢 – 2017-08-01 12:14:21
你可以参考:http://stackoverflow.com/q/1209582/878414 – Vaquita 2012-03-08 09:55:37