Two columns on an uicollectionview

to first have set your desired indentation in viewDidLoad, for example, put the padding on 10

let layout:UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
clnView.collectionViewLayout = layout

and then use this

func collectionView(collectionView: UICollectionView,
        layout collectionViewLayout: UICollectionViewLayout,
        sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
            //device screen size
            let width = UIScreen.mainScreen().bounds.size.width
            //calculation of cell size
            return CGSize(width: ((width / 2) - 15)   , height: 155)
    }

The best way to do this I found is either in Storyboard or in the delegate methods, have an item size of 159 and a gap inbetween gap of 0.5 or even smaller if you want. Just play around with it


By Implementing UICollectionViewDelegateFlowLayout protocol, you can find many methods for implementing layout of UICollectionView.

collectionView:layout:minimumInteritemSpacingForSectionAtIndex:
 collectionView:layout:minimumLineSpacingForSectionAtIndex:

should be enough to solve this.

Also you can implement, numberOfItems and numberOfSections to specify number of row, column.
  Alternatively, you can specify the size of your cells as (width of UICollectionView) / (number of columns you want) - some offset between cells
in cellForItemAtIndexPath.
  By default the cells are calculated by this and arranged accordingly. Just by decreasing the size you will see multi columns. Ref1 Ref2