![](/img/trans.png)
[英]Hide NavigationBar when scrolling tableView in CollectionView?
[英]How can I hide a collectionView when scrolling in my tableView (knowing that this ViewCOntroller is half tableview and half collectionview)
所以我有一個UIViewController
,它具有一個水平滾動的collectionView
(例如newsFeed頁面頂部的facebook故事),在它的下面是帶有單元格的tableView
。 向下滾動tableView
時如何隱藏此集合視圖? 我希望它完全像facebook。
您必須設置collectionView高度約束,並且在開始拖動表格視圖時:
heightConstraint.constant = 0
您可以了解從表視圖委托開始拖動的知識。 為此,您應該從UITableViewDelegate繼承viewController並設置一個函數:
class ViewController: UIViewController, UITableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
print("begin dragging")
heightConstraint.constant = 0
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.