我有一个包含 Collection View 的 View Controller 。在 Collection View 中,我有一个 TableView 。每当我滚动表格 View 时,导航栏都应该隐藏。
- View Controller
- collection view --- Collection View 单元格
- table view ----表格 View 单元格
如何隐藏导航栏?
最佳答案
您可以使用 scrollview 委托(delegate)方法来隐藏和显示导航栏。 检查以下方法
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
self.navigationController?.setNavigationBarHidden(true, animated: true)
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if decelerate == false {
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
希望它对你有用。
关于ios - 如何在滚动 Collection View 内的 TableView 时隐藏导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48520850/