Reputation: 282
I have a horizontally scrolling uicollectionview
with insets I am setting through the uicollectionviewdelegateflowlayout
method insetForSectionAt
.
In trying to use the method .scrollToItem
the scroll doesn't seem to take into account of the inset and only scrolls a part of the way.
Is there a suggested approach to account for the inset and have the scroll go all the way? It is just one section and I am trying to scroll from item 0 to item 1.
Upvotes: 1
Views: 524
Reputation: 4849
Another approach is to manually modify content offset based on a custom calculation.
let customPoint = CGPoint(x: customX, y: customY)
collectionView.setContentOffset(customPoint, animated: true)
Where customX and customY are calculated based on cell size and cell count + other factors such as insetForSection.
Upvotes: 1