Scroll the UICollectionViewCell first to the center of view

I have UICollectionViewone that stretches out on mine UIViewController. I fill it with a horizontal line UICollectionViewCells. Here is my view:

enter image description here

When a user clicks on a contact, I look at it in the center of the view and display the information below.

My problem is with the first and last cells - if I try to scroll them to the center, they will not, because there is nothing left to the left of the first cell or to the right of the last cell. Is there something I can set (for example, an offset or insertion, or an edge or something else) that will allow this first and last cell to scroll right to the middle UICollectionView?

+4
source share
2 answers

In Interface Builder, you can set the insertion options for UICollectionViewhere:

Screen shot

+3
source
yourCollectionView.contentInset = UIEdgeInsetsMake(0, leftWidth, 0, rightWidth);
0
source

Source: https://habr.com/ru/post/1523393/


All Articles