title: How to add UICollectionView Header
body: <p>I wish to add a label to my UICollectionView programmatically, and have used the viewForSupplementaryElementOfKind and referenceSizeForHeaderInSection to set it up, however for some reason when I setup my views it is still placing it inside the first row of my CollectionView instead of the created header. <a href="https://i.stack.imgur.com/IPSbE.png" rel="nofollow noreferrer">As you can see in this screenshot, "Today" is in the first cell, instead of the header I created for it</a> </p>
  
  <pre><code>class TvController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
  
  private let cellId = "cellId"
  private let headerId = "headerId"
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      navigationItem.title = "TV"
      navigationController?.navigationBar.isTranslucent = false
  
      collectionView?.backgroundColor = .white
  
      collectionView?.register(TvCell.self, forCellWithReuseIdentifier: cellId)
      collectionView?.register(Header.self, forCellWithReuseIdentifier: headerId)
  
  }
  
  override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 10
  }
  
  override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath)
  
      return cell
  }
  
  //Row for each TV show
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: view.frame.width, height: 120)
  }
  
  //Today's date header
  override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -&gt; UICollectionReusableView {
      let header = collectionView.dequeueReusableCell(withReuseIdentifier: headerId, for: indexPath) as! Header
  
      return header
  }
  
  //Today's date header
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -&gt; CGSize {
      return CGSize(width: view.frame.width, height: 60)
  }
  }
  </code></pre>
  
  <p>Here is the Header class</p>
  
  <pre><code>class Header: UICollectionViewCell  {
  
  override init(frame: CGRect)    {
      super.init(frame: frame)
      setupHeaderViews()
  }
  
  let dateLabel: UILabel = {
      let title = UILabel()
      title.text = "Today"
      title.textColor = .gray
      title.backgroundColor = .black
      title.font = UIFont(name: "Montserrat", size: 17)
      title.translatesAutoresizingMaskIntoConstraints = false
      return title
  }()
  
  func setupHeaderViews()   {
      addSubview(dateLabel)
  
      dateLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 20).isActive = true
      dateLabel.topAnchor.constraint(equalTo: topAnchor, constant: 10).isActive = true
      dateLabel.widthAnchor.constraint(equalToConstant: 120).isActive = true
      dateLabel.heightAnchor.constraint(equalToConstant: 30).isActive = true
  }
  
  
  required init?(coder aDecoder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
  }
  }
  </code></pre>