Questions tagged [uicollectionviewcompositionallayout]
206 questions
5
votes
3 answers
How can I set different backgrounds for different sections using compositional layout?
I would like to have different backgrounds for different sections in a collection view using compositional layout.
Currently I am using NSCollectionLayoutDecorationItem.background to set the background on a section. However this type of view is not…

TylerJames
- 941
- 8
- 27
5
votes
1 answer
UICollectionViewCompositionalLayout - center items in sections or groups
I set up a collection view and its layout with the new compositional stuff and it has been pretty cool, it seems to be very expandable but I can't find a way to make items centered in the collection, which is IMO a basic feature that one would…

nknr
- 123
- 6
5
votes
1 answer
UICollectionView for non-grid or semi-grid layout
I am trying to implement a multi-row sequence of items (like Video editing sequence in Final Cut Pro or Adobe Premiere pro shown below).
While I one can always implement it using UIScrollView and placing custom views manually, it would be tedious…

Deepak Sharma
- 5,577
- 7
- 55
- 131
5
votes
1 answer
Collection View Diffable Data Source cells disappearing and not resizing properly?
I'm having a really weird issue with my collection view. I'm using the Compositional Layout and Diffable Data Source APIs for iOS 13+, but I'm getting some really weird behavior. As seen in the video below, when I update the data source, the first…

bryan-vh
- 151
- 1
- 9
4
votes
1 answer
UICollectionViewCompositionalLayout Dynamic Heights Causing Layout Adjustments and Flickering
I'm using UICollectionViewCompositionalLayout to create a vertically scrolling list of horizontally scrolling (orthogonally scrolling) lists in my iOS app.
When I specify an estimated height for both the item and the group, the collection view…

Aodh
- 662
- 1
- 7
- 24
4
votes
1 answer
Collection view self-sizing cells issue in Compositional layout
I am using a collection view compositional layout to display a cell with two labels that can grow in height, depending on the content of the labels. Everything else in the cell is fixed.
I make a section like this:
let item =…

annaoomph
- 552
- 1
- 4
- 22
4
votes
0 answers
scrollToItem() causes compositional layout to glitch when using paging
I'm using UICollectionViewCompositionalLayout and the *UICollectionLayoutSectionOrthogonalScrollingBehavior to build a carousel.
The scrollToItem() method will correctly scroll to the item at the specified indexPath but will create a top-inset…

David Schmoecker
- 567
- 3
- 8
- 17
4
votes
3 answers
How to deal with empty items section in UICollectionView CompositionalLayout
I'm trying to make collection view with compositional layout which have multi sections
but if there is empty items in sections how can I deal with it?
if item is empty I don't want to show that section
UICollectionViewCompositionalLayout { (section,…

PrepareFor
- 2,448
- 6
- 22
- 36
4
votes
0 answers
How do I create stretchy header in compositional layout?
class StretchyHeader: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let layoutAttributes = super.layoutAttributesForElements(in: rect)! as…

skylin
- 51
- 4
4
votes
1 answer
Compositional Layout item with .estimated width crashes app when content is too long
I'm exploring the amazing world of using Compositional Layout and I've found a small situation that I need help with. Below there is a simple app that uses a CollectionView with CL to display random strings using a UIListContentConfiguration rounded…

rudymatos
- 321
- 1
- 3
- 12
4
votes
1 answer
Page control in compositional layout collection view
I'm trying to use pageControl option in compositional layout collection view.I already referred some previous questions related to same topic, like this Trying to hook up Compositional Layout CollectionView with PageControl.…

AxSu
- 41
- 3
4
votes
1 answer
UICollectionVIew Compositional Layout & DiffableDataSource, how to enable data prefetching?
How to enable data prefetching when using the new Compositional Layout & DiffableDataSource?
Before, we can achieve this by conforming a custom data source object, like,
class CustomDataSource: NSObject, UICollectionViewDataSource,…

zrfrank
- 2,631
- 1
- 12
- 18
4
votes
1 answer
How to make a UICollectionView global header and/or footer?
I’ve been trying to create a UICollectionView header that would stick on top of my collection view. I’m using UICollectionViewCompositionalLayout.
I’ve tried multiple approaches: using a cell, using a section header and try to mess with insets and…

Clément Cardonnel
- 4,232
- 3
- 29
- 36
4
votes
1 answer
Can make this layout with a UICollectionViewCompositionalLayout
I am trying to create a 'tag cloud' section using a UICollectionViewCompositionalLayout
I would like a full width section of items followed by a section that wraps in this fashion
Essential HR, Financial Wellbeing and Employee engagement would each…

Harry Blue
- 4,202
- 10
- 39
- 78
4
votes
0 answers
UICollectionViewCompositionalLayout orthogonal section willDisplayCell analytics
I'm using Collection View Compositional Layout and need to have accurate analytics for "userViewedCell" events for orthogonally scrolling sections. I had been using collectionView(willDisplay:forItemAt) to detect when a cell is about to be shown,…

gracie
- 41
- 2