结合scrollView的代理方法,根据偏移位置位置进行判断;
#pragma mark ScrollView
//开始移动
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
self.nowScrollViewOffset = scrollView.contentOffset;//开始滑动时记录初始位置,与下边的最终位置进行比较,做出相应的操作; self.nowScrollViewOffset的类型为 CGPoint;
}
//结束移动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if ((scrollView.contentSize.height - scrollView.frame.size.height) < 80) {
return;
}if ((scrollView.contentOffset.y - self.nowScrollViewOffset.y > 20)){//向下偏移20
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self.navigationController setNavigationBarHidden:NO];
self.tabBarController.tabBar.hidden = YES;//隐藏
}
if ((scrollView.contentOffset.y - self.nowScrollViewOffset.y) < 0) {
self.tabBarController.tabBar.hidden = NO;//出现
}
}