Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set offset or initial position for a cell in a collection view

I want to add some space before the first cell in a collection view, something like an offset, my collection view has a horizontal scroll position.

Here is my current collection view:

current

It has a leading constraint of 35, what I want is the cell to start at an "x" position of 35 but with the ability to scroll full width like in this:

desired

Is there a way to create that initial offset in a collection view using Swift 3?

like image 257
Jonathan Solorzano Avatar asked Jun 21 '17 15:06

Jonathan Solorzano


1 Answers

You could just set Section Insets for Collection View Flow Layout without code.

enter image description here

like image 120
Alexander Spirichev Avatar answered Oct 28 '22 23:10

Alexander Spirichev