Alex Rivera | Logout

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

Asked 2012-03-02T09:00:57.020
12

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?

Edit
Report

2 Answers

27

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

answered 2012-03-03T10:49:04.743
6

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

}
answered 2013-06-05T22:20:22.803

Your Answer