iOS之NavigationBar随滑动隐藏或显示
用UIScrollViewDelegate方法
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
CGFloat velocity = [pan velocityInView:scrollView].y;
if (velocity < -5) {
[self.navigationController setNavigationBarHidden:YES animated:YES];
}else if(velocity > 5){
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
}
获取拖拽速度:velocity>0为向下拖拽, velocity<0为向上拖拽