Hide NavigationBar when scrolling tableView in CollectionView?

前端 未结 6 1598
一整个雨季
一整个雨季 2020-12-05 11:47

I have collectionViewController and collectionViewCell include TableView.CollectionView is horizontal layout.I want hide navigationbar when scroll the tableView. Is there an

6条回答
  •  星月不相逢
    2020-12-05 12:28

    Try this:

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if scrollView.panGestureRecognizer.translation(in: scrollView).y < 0 {
            navigationController?.setNavigationBarHidden(true, animated: true)
        } else {
            navigationController?.setNavigationBarHidden(false, animated: true)
        }
    }
    

提交回复
热议问题