第一种做法:
- (void)scrollViewDidScroll:(UIScrollView*)scrollView
{
CGFloatoffsetY = scrollView.contentOffset.y+self.tableView.contentInset.top;
CGFloatpanTranslationY =[scrollView.panGestureRecognizertranslationInView:self.tableView].y;
if(offsetY >0) {
if(panTranslationY >0) {
//下滑趋势显示
[selfdownScroll];
}else{
//上滑趋势隐藏
[selfupScroll];
}
}else{
//下滑趋势显示
[selfdownScroll];
}
}
第二种做法:
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
if(velocity.y > 0) {
//上滑 隐藏
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
else {
//下滑 出来
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
}
网友评论