Hide UITabBarController/UITabBar with animation.
Categories: iPhone on Nov.20, 2009
Hide UITabBarController/UITabBar with animation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | BOOL hiddenTabBar; UITabBarController *tabBarController; - (void) hideTabBar { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.4]; for(UIView *view in tabBarController.view.subviews) { CGRect _rect = view.frame; if([view isKindOfClass:[UITabBar class]]) { if (hiddenTabBar) { _rect.origin.y = 431; [view setFrame:_rect]; } else { _rect.origin.y = 480; [view setFrame:_rect]; } } else { if (hiddenTabBar) { _rect.size.height = 431; [view setFrame:_rect]; } else { _rect.size.height = 480; [view setFrame:_rect]; } } } [UIView commitAnimations]; hiddenTabBar = !hiddenTabBar; } |
Similar posts:
November 23rd, 2009 on 12:35 pm
Полезый метод, думаю, пригодится. Только есть один баг. В последнем ифе нужно поменять местами [view sefFrame:]
if (hiddenTabBar) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
November 23rd, 2009 on 6:00 pm
да! извиняюсь!
ночью писал.
April 22nd, 2010 on 9:44 am
Thanks
I use that SampleCode well
but Big Problem is remain,
The view have Enable(false) Frame That UITabbar Frame.
UITabbar Hide Success but The Frame can’t use. Help!
April 26th, 2010 on 10:40 am
Great ! Thank you very much !
June 17th, 2010 on 3:27 am
Thanks! It works!
July 15th, 2010 on 7:02 pm
I think the solution looks dirty.
You only need to set
self.hidesBottomBarWhenPushed=YES;
in UIViewController of the Controller which is pushed and everything works fine!
July 15th, 2010 on 7:15 pm
@Sebastian if you use UINavigationController, yes. In another not!
August 5th, 2010 on 4:35 pm
Thanks m8 I like it!! :D
September 26th, 2010 on 9:58 pm
your code is cool.
i use your code but I am embarrassed.
uitabbarcontroller have uiviewcontroller
uiviewcontroller have uitoolbar
i want to move tabbar hidden but
I do not want to move uitoolbar
(uitoolbar is (0,0,320,44) )
How should I do?
March 17th, 2011 on 8:33 pm
Thanks for the code. It is working well!
August 23rd, 2011 on 7:45 am
you are great pal . i tried nearly for one hour to get the result. it happened only because of you
September 20th, 2011 on 3:09 pm
thanks alot , it’s useful :)
December 21st, 2011 on 5:28 am
Modified the code to work on both iPad (tested in simulator) & iPhone (not tested, but hopefully it will work)