我对UITabBarController
有问题.在我的应用程序中,我想隐藏它,但不使用hidesBottomBarWhenPushed
,因为我不想在按下它时隐藏它.例如,我想在应用程序中按下隐藏按钮时隐藏它.
我在谷歌上看了很多文章,但我找不到如何做到这一点.
我对UITabBarController
有问题.在我的应用程序中,我想隐藏它,但不使用hidesBottomBarWhenPushed
,因为我不想在按下它时隐藏它.例如,我想在应用程序中按下隐藏按钮时隐藏它.
我在谷歌上看了很多文章,但我找不到如何做到这一点.
我正在从我的工作代码中粘贴这个.您可以调用这些方法来隐藏和显示选项卡栏控制器.只需将tabbarController实例传递给这些函数即可.
// Method call
[self hideTabBar:self.tabBarController];
// Method implementations
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(@"%@", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}