So I have a UIViewController
that have a collectionView
with horizontal scrolling (like the facebook stories on the top of newsFeed page) and under it is the tableView
with cells. How can I hide this collection view when I scroll down the tableView
? I want it to exactly like facebook.
You have to set collectionView height constraint, and when you begin dragging table view:
heightConstraint.constant = 0
You can know about start dragging from table view delegate. For this you should inherit your viewController from UITableViewDelegate and set a function :
class ViewController: UIViewController, UITableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
print("begin dragging")
heightConstraint.constant = 0
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.