代码如下:
// 开始拖拽
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
oldY = scrollView.contentOffset.y;
}
// 滚动时调用此方法(手指离开屏幕后)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if(scrollView.contentOffset.y > oldY) {
[self.navigationController setNavigationBarHidden:YES animated:YES];
}else{
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
}
// 完成拖拽(滚动停止时调用此方法,手指离开屏幕前)
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
}