When i initially added a sectionHeader to my collectionView it did appear as normal. I had this in my collectionViewController.swift and had a class for the header.
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "header", for: indexPath) as! HomeHeader
return header
}
Once I added this to viewDidLoad() the header no longer appears.
let cellsAcross: CGFloat = 2
let spaceBetweenCells: CGFloat = 5
let dimX = ((collectionView?.bounds.width)! - (cellsAcross - 1) * spaceBetweenCells) / cellsAcross
let dimY = CGFloat(dimX/187 * 125)
let cellSize = CGSize(width: dimX , height: dimY)
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical
layout.itemSize = cellSize
//layout.sectionInset = UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1)
layout.minimumLineSpacing = 5.0
layout.minimumInteritemSpacing = 5.0
collectionView?.setCollectionViewLayout(layout, animated: true)
collectionView?.reloadData()
I have this to force it to display two rows of cells on all screen sizes. (I'm still having an issue with that not resizing all the content in the cell though).
I'm not sure why the header no longer appears
(I'm using Swift 3)