Here would be my approach -
- Create outlets for your header and your contents.
- Get the height of your contents
- Set the height of your header as a % of the contents
In your View Controller -
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = yourCollectionView.dequeueReusableCellWithReuseIdentifier("YourCustomCell", forIndexPath: indexPath) as! YourCustomeCell
...
cell.setUpCell()
return cell
}
In your View Cell -
@IBOutlet weak var headerView: UIView!
@IBOutlet weak var contentView: UIView!
func setUpCell() {
let percentageYouWant = 0.3
let newFrame = CGRect(x: 0, y: 0, width: contentView * percentageYouWant, height: contentView * percentageYouWant)
headerView.frame = newFrame
}