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

后端 未结 3 718
离开以前
离开以前 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 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];
        }
    
    }
    

提交回复
热议问题