UITabBar is a top-level view, which means that almost all views are under it. Even the UINavigationController sits below the tabBar.
You can hide the tabBar as follows:
- (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]; }
And then return it like this:
- (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 has a height of 50 pixels by default. Therefore, you just need to set a new frame height and animate it.
source share