Home » iPhone » Hide UITabBar of UITabBarController with animation.

Hide UITabBar of UITabBarController with animation.

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;
}

13 thoughts on “Hide UITabBar of UITabBarController with animation.

  1. Полезый метод, думаю, пригодится. Только есть один баг. В последнем ифе нужно поменять местами [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)];
    }

  2. 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!

  3. 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!

  4. 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?

  5. you are great pal . i tried nearly for one hour to get the result. it happened only because of you

Comments are closed.