在ios 11中滚动uicollectionView时如何隐藏导航栏?

问题描述 投票:0回答:1

在iOS 11中,如果我们设置为隐藏,则在滚动tableView时会隐藏searchBar。滚动collectionView时如何隐藏searchBar,navigationBar和tabBar?向下滚动时取消隐藏所有内容?谢谢你的帮助...

ios11 smooth-scrolling collectionview searchbar
1个回答
3
投票
  1. UIViewController中的子类UIScrollViewDelegate(即class ViewController: UIViewController, UIScrollViewDelegate { codes... }
  2. 实现scrollViewDidScroll Delegate方法 func scrollViewDidScroll(scrollView: UIScrollView) { let pan = scrollView.panGestureRecognizer let velocity = pan.velocityInView(scrollView).y if velocity < -5 { self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.setToolbarHidden(true, animated: true) } else if velocity > 5 { self.navigationController?.setNavigationBarHidden(false, animated: true) self.navigationController?.setToolbarHidden(false, animated: true) } }
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.