I have a UICollectionView attached to the Top Layout tutorial (I use the NavigationController to attach to the navigation bar) and aligned to the bottom of the image that it overlays.
I hide the navigation bar and animate the position of the image, which means due to the limitations that CollectionView also moves.
In the scrollViewDidScroll delegate method of my scrollView, I animate them like this:
if scrollView.panGestureRecognizer.translation(in: scrollView).y > 0 {
navigationController?.setNavigationBarHidden(false, animated: true)
UIView.animate(withDuration: 0.2, animations: {
self.topImageContraintToTop.constant = 0
self.view.layoutIfNeeded()
})
} else {
navigationController?.setNavigationBarHidden(true, animated: true)
UIView.animate(withDuration: 0.2, animations: {
self.topImageContraintToTop.constant = -(self.navigationController?.navigationBar.bounds.size.height)! - 10
self.view.layoutIfNeeded()
})
}
Thus, every time this animation occurs, the visible CollectionView cells flash / flash briefly.
I was looking for a watch to solve, but so far nothing has helped.
I would be grateful for any approach to this problem.