导航

iOS 实现ScrollView 上滑隐藏Navigationb

2016-03-19  本文已影响679人  husky_duang

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);

}

上一篇下一篇

猜你喜欢

热点阅读