CGFloat lastContentOffsetY;
//即将开始拖拽,记录滑动前的偏移量
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
lastContentOffset = scrollView.contentOffset.y;
}
//滑动过程中
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y < lastContentOffset)
{
[self.navigationController setNavigationBarHidden:NO animated:YES];//向上
} else if (scrollView.contentOffset.y > lastContentOffset)
{
[self.navigationController setNavigationBarHidden:YES animated:YES];//向下
}
}