How to set the space between rows and columns of an NSCollectionView?

I created a collection view and I cannot allocate space between the elements of the collection view. So please help .... Thanks in advance ...

I used this link to create a collection view https://andrehoffmann.wordpress.com/2009/08/29/nscollectionview-tutorial-for-dummies-xcode-3-1-3/

+6
source share
2 answers

If you use a storyboard to create an update to the collection view, Min Spacing and Section Inset as

enter image description here

0
source

You need to change the layout of the CollectionView. Probably the easiest thing is to make it a Flow layout and set its properties there. Here is an example:

 let layout = UICollectionViewFlowLayout() layout.minimumInteritemSpacing = 5 layout.sectionInset = EdgeInsets(top: 10, left: 10, bottom: 10, right: 10) layout.minimumLineSpacing = 8 self.collectionView.collectionViewLayout = layout 

If you want to do much more than this with respect to the layout of the elements, you need to subclass the UICollectionViewLayout and override the various layout methods.

-1
source

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


All Articles