如何使tableview上拉隐藏navigationBar往下拉又显示

2025-05-07 04:40:10
推荐回答(1个)
回答1:

  一个prePoint作为参考,在scrollview的委托中根据滑动时的contentoffset的y坐标与prePoint之差来判断滑动方向。

  

  scrollview有一个delegate是带有速度参数velocity,你实现这个代理,然后判断速度的方向velocity.y的正负值来判断scrollview的运动方向。

  

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(CGPoint *)targetContentOffset
{
NSLog( @"scrollViewWillEndDragging" );
if (velocity.y > 0) {
[self.nav