riteshhgupta / TagCellLayout

Made in Swift - Tag layout for UICollectionView supporting 3 types of alignments - Left || Centre || Right
MIT License
358 stars 36 forks source link

Question: Programmatically Set Section Inset? #17

Closed tylerswartz closed 6 years ago

tylerswartz commented 7 years ago

👋 Ritesh -

I'm having trouble setting the insets for my CollectionView programmatically (I'm not using a story board). Right now it's taking up the entire view, but I need it to appear below some text and above a button at the bottom of the view.

For a typical UICollectionView I've used sectionInset to set it in the proper position:

let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 178, left: 10, bottom: 40, right: 10)
collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)

This doesn't seem to work for tagCellLayout. Any ideas?

Thanks for the help 😊

riteshhgupta commented 6 years ago

Hey @tylerswartz, TagCellLayout uses UICollectionViewLayout as super class and sectionInset is only available in UICollectionViewFlowLayout.

tylerswartz commented 6 years ago

Thanks for the reply. I ended up embedding it within a container view and apply the insets there. That did the trick.