Bat*_*Can 1 smooth-scrolling collectionview searchbar ios11
在 iOS 11 中,如果我们设置为隐藏,则在滚动 tableView 时 searchBar 会隐藏。向上滚动 collectionView 时如何隐藏 searchBar、navigationBar 和 tabBar?并在向下滚动时取消隐藏它们?谢谢你的帮助...
小智 5
class ViewController: UIViewController, UIScrollViewDelegate { codes... }
)实现 scrollViewDidScroll 委托方法
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)
}
}
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
2686 次 |
最近记录: |