我在標籤欄應用程序工作。如何隱藏特定視圖中的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