Custom footer view for UICollectionview in quick

I rewrote the objective-C min application in swift and decided that viewing the collection works better than tableview in my case. So I have a collection that is configured exactly the way I want it, and now I need to add a footer to my collection view.

In objective-C, it was very easy for me, all I did was create a UIView, add objects to it and add it to my table, like this.

self.videoTable.tableFooterView = footerView;

Now I’m trying to get a similar solution in my view of the collection, but so far I’m out of luck.

Is there a simple .collectionviewFooterView or something that I can add to a UIView?

EDIT I found similar ideas HERE if this helps create an answer

EDIT

I was thinking of ways to achieve this, so now I want to add a footer at the end of the collection view using the following code:

var collectionHeight = self.collectionView.collectionViewLayout.collectionViewContentSize().height

footerView.frame = CGRectMake(0, collectionHeight, screenSize.width, 76)

The only problem I encounter with this workaround is that I need to add more space to the contentView colletionView and I have no luck with this

My decision

I solved this using a workaround (not the prettiest one, but it works), I add a UIView to the uicollectionview with a simple

footerView.frame = CGRectMake(0, collectionHeight - 50, screenSize.width, 50)
self.collectionView.addSubview(footerView)

and set the layout inserts using this:

alLayout.contentInsets = UIEdgeInsetsMake(2, 2, 52, 2)
+4
source share
1 answer

Collection views handle headers and footers differently than table views. You will need:

  • Register a footer view class using:

    registerClass(myFooterViewClass, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: "myFooterView")
    
  • headerReferenceSize , collectionView:layout:referenceSizeForHeaderInSection: delegate.

  • dataSource:

    func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
        let view = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier: "myFooterView", forIndexPath: indexPath)
        // configure footer view
        return view
    }
    

, !

+9

All Articles