动画隐藏Navbar【上滑推动Navbar至消失,下滑至完全出现Navbar的】

NavigationViewController+TableView(或者ScrollView )情况

//首先设置navigationBar.translucent
    UINavigationController *navVC = [[UINavigationController alloc]initWithRootViewController:self.viewController];
    navVC.navigationBar.translucent = YES;

 //然后设置tabelView.contentInset,不然table会显示在navbar后面一部分
    self.tabelViewFollows.contentInset = UIEdgeInsetsMake(44.0f, 0.0f, 0.0f, 0.0f);

//最后在scrollViewDidScroll进行判断来设置navbar
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    NSInteger num = scrollView.contentOffset.y + 44;
    
    if (num<0) {
        num=0;
    }
    if (num>44) {
        num =44;
    }
    self.navigationController.navigationBar.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 0.f,-num);
    
}


你可能感兴趣的:(uiscrollview,UINavigationBar)