I feel this should be simple to accomplish but for some reason im lost. I have a button that will scroll a UICollectionView so the cell at an given IndexPath is top of the screen. problem is that the method does not take into account the supplementary header view. so :
collectionView?.scrollToItem(at: indexP, at: UICollectionViewScrollPosition.top, animated: true)
actually means the cell disappears under the header. How best to resolve so that calling UICollectionViewScrollPosition.top
scrolls to the top under the header?
in the viewDidLoad of my UICollectioViewController
let layout = collectionView?.collectionViewLayout as? UICollectionViewFlowLayout
layout?.sectionHeadersPinToVisibleBounds = true