Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Modified Setomidor's answer to work on both landscape, portrait, and iPad (the 320 and 480 values only work on iPhone).</p> <pre><code>- (void) hideTabBar:(UITabBarController *) tabbarcontroller { CGRect screenRect = [[UIScreen mainScreen] bounds]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; float fHeight = screenRect.size.height; if( UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) ) { fHeight = screenRect.size.width; } for(UIView *view in tabbarcontroller.view.subviews) { if([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)]; view.backgroundColor = [UIColor blackColor]; } } [UIView commitAnimations]; } - (void) showTabBar:(UITabBarController *) tabbarcontroller { CGRect screenRect = [[UIScreen mainScreen] bounds]; float fHeight = screenRect.size.height - tabbarcontroller.tabBar.frame.size.height; if( UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) ) { fHeight = screenRect.size.width - tabbarcontroller.tabBar.frame.size.height; } [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, fHeight, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)]; } } [UIView commitAnimations]; } </code></pre> <p>Also modified the code to handle changes introduced in iOS 6 with UIDevice orientation change and ensure that it works properly even when the device is lying on its back.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload