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

后端 未结 3 674
离开以前
离开以前 2021-02-02 01:18

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 scr

相关标签:
3条回答
  • 2021-02-02 01:57

    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

    0 讨论(0)
  • 2021-02-02 02:06

    I would probably try to create my own root controller with scrollbar as main view and put navigation controller's view into it. You can't use scrollbar inside navbar view then but I believe you don't need it in this very case.

    If this approach doesn't work I would probably create my own controller that mimic navigation controller appearance.

    0 讨论(0)
  • 2021-02-02 02:12

    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];
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题