Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create pinterest style hiding/unhiding nav/tab bar?

How do I create a hiding/unhiding nav bar like what pinterest and many other apps is doing? I know the basic idea is to use the UIScrollView delegate and detect whether I am scrolling up or down and show the nav bar based on that. So should I also adjust the navcontroller view height if the nav bar is hidden? How does this work?

like image 696
adit Avatar asked Mar 02 '12 09:03

adit


Video Answer


2 Answers

I have a sample project located on github that does exactly the pinterest/piictu style 'hide the UINavigationController / UITabBarController stuff'

https://github.com/tonymillion/ExpandingView

like image 61
Tony Million Avatar answered Oct 21 '22 23:10

Tony Million


I've tried https://github.com/tonymillion/ExpandingView and ran into a bunch of issues.

I ended up rolling my own navigation controller to get all the animations synced and used this scrollview code to figure out if I should expand or contract. iOS >=5.0

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    MyCustomNavController* navController = (MyCustomNavController*)self.parentViewController;
    if( [scrollView.panGestureRecognizer translationInView:self.view].y  < 0.0f ) {
        [navController setExpanded:YES animated:YES];
    } else if ([scrollView.panGestureRecognizer translationInView:self.view].y  > 0.0f  ) {
        [navController setExpanded:NO animated:YES];
    }

}
like image 27
Nico Avatar answered Oct 21 '22 22:10

Nico