在iOS 11中,如果我们设置为隐藏,则在滚动tableView时会隐藏searchBar。滚动collectionView时如何隐藏searchBar,navigationBar和tabBar?向下滚动时取消隐藏所有内容?谢谢你的帮助...
class ViewController: UIViewController, UIScrollViewDelegate { codes... }
)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)
}
}