gpt4 book ai didi

iphone - 如何隐藏uitabbarcontroller

转载 作者:IT王子 更新时间:2023-10-29 07:31:25 24 4
gpt4 key购买 nike

我对 UITabBarController 有疑问。在我的应用程序中,我想隐藏它但不使用 hidesBottomBarWhenPushed 因为我不想在推送它时隐藏它。例如,当我在我的应用程序中按下隐藏按钮时,我想隐藏它。

我在谷歌上阅读了很多文章,但我无法找到如何做到这一点。

最佳答案

我从我的工作代码中粘贴了这个……你可以调用这些方法来隐藏和显示 tabbarcontroller……只需将 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];
}

关于iphone - 如何隐藏uitabbarcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5272290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com