I have collectionViewController and collectionViewCell include TableView.CollectionView is horizontal layout.I want hide navigationbar when scroll the tableView. Is there an
func scrollViewDidScroll(_ scrollView: UIScrollView)
{
// var navigationBarFrame = self.navigationController!.navigationBar.frame
let currentOffset = scrollView.contentOffset
if (currentOffset.y > (self.lastContentOffset?.y)!) {
if currentOffset.y > 0 {
initial = initial - fabs(CGFloat(currentOffset.y - self.lastContentOffset!.y))
}
else if scrollView.contentSize.height < scrollView.frame.size.height {
initial = initial + fabs(CGFloat(currentOffset.y - self.lastContentOffset!.y))
}
}
else {
if currentOffset.y < scrollView.contentSize.height - scrollView.frame.size.height {
initial = initial + fabs(CGFloat(currentOffset.y - self.lastContentOffset!.y))
}
else if scrollView.contentSize.height < scrollView.frame.size.height && initial < maxPlus {
initial = initial - fabs(CGFloat(currentOffset.y - self.lastContentOffset!.y))
}
}
if (initial <= maxMinus){
initial = maxMinus
self.tableviewTopConstrin.constant = 0
UIView.animate(withDuration: 0.4, animations: {
self.view.layoutIfNeeded()
})
}else if(initial >= maxPlus){
initial = maxPlus
self.tableviewTopConstrin.constant = 70
UIView.animate(withDuration: 0.4, animations: {
self.view.layoutIfNeeded()
})
}else{
}
self.lastContentOffset = currentOffset;
}