iOS 实现ScrollView 上滑隐藏Navigationbar,下滑显示

1》//滑动隐藏导航栏,效果

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview];

[self.navigationController setNavigationBarHidden:translation.y<0 animated:YES];

NSLog(@"ContentOffset  x is  %f,yis %f",translation.x,translation.y);

}

《2》//滑动隐藏导航栏, 结束时两个方向有速度,才执行

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview];

[self.navigationController setNavigationBarHidden:translation.y<0 animated:YES];

NSLog(@"ContentOffset  x is  %f,yis %f",translation.x,translation.y);

}

你可能感兴趣的:(iOS 实现ScrollView 上滑隐藏Navigationbar,下滑显示)