在 appdel 中添加以下方法,您可以在任何视图控制器中调用此方法来显示和隐藏 tabbbar。只需在要显示和隐藏 tabBar 的任何地方调用此方法。
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
// [UIView beginAnimations:nil context:NULL];
// [UIView setAnimationDuration:0.1];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, ([UIScreen mainScreen].bounds.size.height == 568.0 ? 568:480)+20, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height == 568.0 ?568: 480)];
}
}
// [UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, ([UIScreen mainScreen].bounds.size.height == 568.0 ? 519: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, [UIScreen mainScreen].bounds.size.height == 568.0 ? 519:431)];
}
}
// [UIView commitAnimations];
}