TabelView下拉顶掉NavigationBar

#pragma mark - 滚动就调用  滑动隐藏导航栏
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    CGFloat offsetY = scrollView.contentOffset.y + _tableView.contentInset.top;
    
    CGFloat panTranslationY = [scrollView.panGestureRecognizer translationInView:self.tableView].y;

    if (offsetY > 64) {
        
        [self showAndHidden:panTranslationY];

    } else {
        
        [self.navigationController setNavigationBarHidden:NO animated:YES];

    }

}

- (void)showAndHidden:(CGFloat)panTranslationY {
    
    if (panTranslationY > 0) {
        
        //下滑趋势 的时候显示
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        
    }
    else {
        
        //上滑趋势,隐藏
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }
    
}


学自简书/ 霖溦

原文链接:http://www.jianshu.com/p/b2585c37e14b



我的Demo点此下载


原github点此:

https://github.com/kukumaluCN/JXT_iOS_Demos


你可能感兴趣的:(TabelView下拉顶掉NavigationBar)