Pages

Saturday, April 16, 2011

How to hide/show Tab bar animatingly with iphone sdk:


Here we are using UIView Animation and set frame to hide and show the tab bar.
BOOL hiddenTabBar;
- (void) hidetabbar {
           
            [UIView beginAnimations:nil context:NULL];
            [UIView setAnimationDuration:0.5];
           
            for(UIView *view in self.tabBarController.view.subviews)
            {
                   NSLog(@"%@", view);
                  
                   if([view isKindOfClass:[UITabBar class]])
                   {
                            
                             if (hiddenTabBar) {
                                      [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
                             } else {
                                      [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
                             }
                   } else {
                             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)];
                             }
                            
                   }
            }
           
            [UIView commitAnimations];       
            hiddenTabBar = !hiddenTabBar;
}

Happy programming................ 

2 comments:

  1. any chance you have a demo project implementing this?

    ReplyDelete
  2. NO..........

    I had, but now i do not have.

    ReplyDelete