title: Why can't I get a header for a UICollectionView?
body: <p>I'm attempting to create a UICollectionView of grouped images (<em>currently using random images from internet</em>), with each group having their own header.
  <p>
  My problem is - I can't get the header view to display correctly.
  <br/>
  I set the header view's background color to yellow.</p>
  
  <p>Here's the header view: <br/>
  <img src="https://i.stack.imgur.com/ZmHKy.png" alt="enter image description here">
   <br/>
  The following is the current collection with the two groups and their respective headers:</p>
  
  <p><img src="https://i.stack.imgur.com/1I1Jl.png" alt="enter image description here"></p>
  
  <p><p>
  As you can see, the headers have been resized to the size of their member cells and positioned within the collection rather than in their intended header position.
  <p>
  Here's the layout code: <br/></p>
  
  <pre><code>override func viewDidLoad() {
  
  createFriends(sender:self)
  let layout = UICollectionViewFlowLayout()
  layout.scrollDirection = .Vertical;
  layout.itemSize = CGSizeMake(50.0, 50.0);
  layout.sectionInset = UIEdgeInsetsMake(10.0, 10.0, 50.0, 10.0);
  layout.headerReferenceSize = CGSizeMake(320.0, 40.0)
  
  layout.minimumLineSpacing = 10.0;
  layout.minimumInteritemSpacing = 10.0;
  
  gCollectionView.collectionViewLayout = layout
  
  let myNib = UINib(nibName: "(1.1)HeaderViewCell",bundle: nil)
  gCollectionView.registerNib(myNib, forCellWithReuseIdentifier: kCellIdentifier)
      }
  </code></pre>
  
  <p><p>
  Here's the header code (<em>probably don't need the reference size, being that it was set in the layout</em>): <br/></p>
  
  <pre><code>func collectionView(collectionView: UICollectionView, layout 
            collectionViewLayout: UICollectionViewLayout,
            referenceSizeForHeaderInSection section: Int) -&gt; CGSize {
       return CGSizeMake(100.0, 30.0)
  }
  
  
  func collectionView(collectionView: UICollectionView, 
                       viewForSupplementaryElementOfKind kind: String,
                       atIndexPath indexPath: NSIndexPath) -&gt; 
                       UICollectionReusableView {
  
  
      let headerView = 
      collectionView.dequeueReusableCellWithReuseIdentifier(kCellIdentifier, 
           forIndexPath: indexPath) as mediaHeaderView
  
      headerView.backgroundColor = UIColor.yellowColor()  // ... YELLOW background
      return headerView          
  }
  </code></pre>
  
  <p><p>
  <strong>Question:</strong> Why don't I get proper-positioned header per group of items?</p>