Created
September 10, 2013 10:08
-
-
Save borut-t/6507423 to your computer and use it in GitHub Desktop.
Revisions
-
borut-t created this gist
Sep 10, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ // // UITabBarController+extra.m // // Created by Borut Tomažin on 10/1/12. // Copyright (c) 2012 Borut Tomažin. All rights reserved. // #import "UITabBarController+extra.h" #define kAnimationDuration .3 @implementation UITabBarController (extra) - (void)setHidden:(BOOL)hidden animated:(BOOL)animated { CGRect screenRect = [[UIScreen mainScreen] bounds]; float fHeight = screenRect.size.height; if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) { fHeight = screenRect.size.width; } if (!hidden) { fHeight -= self.tabBar.frame.size.height; } CGFloat animationDuration = animated ? kAnimationDuration : 0.f; [UIView animateWithDuration:animationDuration animations:^{ for (UIView *view in self.view.subviews){ if ([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)]; } else { if (hidden) { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)]; } } } } completion:^(BOOL finished){ if (!hidden){ [UIView animateWithDuration:animationDuration animations:^{ for(UIView *view in self.view.subviews) { if (![view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)]; } } }]; } }]; } @end