上下滑動隱藏顯示導航欄

// 導航欄隱藏ci

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

    

    //    NSLog(@"offset---scroll:%f",self.tableView.contentOffset.y);io

    

    //scrollView已經有拖拽手勢,直接拿到scrollView的拖拽手勢table

    UIPanGestureRecognizer* pan = scrollView.panGestureRecognizer;scroll

    //獲取到拖拽的速度 >0 向下拖動 <0 向上拖動im

    CGFloat velocity = [pan velocityInView:scrollView].y;拖拽

    

    if (velocity<-5) {tab

        

        //向上拖動,隱藏導航欄animate

        [self.navigationController setNavigationBarHidden:true animated:true];vi

    }

    else if (velocity>5) {

        //向下拖動,顯示導航欄

        [self.navigationController setNavigationBarHidden:false animated:true];

    }

    else if(velocity==0){

        

        //中止拖拽

    }

}

相關文章
相關標籤/搜索