Questions tagged [uicollectionviewcompositionallayout]
206 questions
18
votes
4 answers
UICollectionViewCompositionalLayout bug on iOS 14.3
I'm experiencing a weird layout issue on iOS 14.3 with collection views using a UICollectionViewCompositionalLayout combined in my case with the UICollectionViewDiffableDataSource.
The issue is about the wrong position of the inner…

alfogrillo
- 519
- 5
- 15
12
votes
0 answers
UICollectionView Compositional Layout header with pinToVisibleBounds is strangely obscured by cells
I am using UICollectionView Compositional Layout and want to have a header that is sticking to the top
this should be possible with
header.pinToVisibleBounds = true
however, during scrolling, the header gets strangely obscured, looking like a…

Peter Lapisu
- 19,915
- 16
- 123
- 179
11
votes
0 answers
UICollectionViewCompositionalLayout : Dynamic height UICollectionView cell, what value should be .estimated to have good performance and right height?
I am able to achieve UICollectionView with dynamic height cell, as shown in the following screenshot. Height of the cell will be automatically adjusted based on content.
Here's is the code to achieve such outcome.
private func updateListLayout() {
…

Cheok Yan Cheng
- 47,586
- 132
- 466
- 875
9
votes
2 answers
Make NSCollectionLayoutItem heights as tall as the NSCollectionLayoutGroup when using estimated heights in a UICollectionViewLayout grid
I have a UICollectionViewLayout grid with three columns. Each item in the column has a cell full of text. I would like all the columns to be the same height as the tallest item in the group. Using UICollectionViewCompositionalLayout I'm having a…

Richard Witherspoon
- 4,082
- 3
- 17
- 33
8
votes
0 answers
Diffable Data Source Scrolls to Top After Applying Snapshot with All New Data in Collection View
I have a collection view (using a compositional layout and a diffable data source) that has a segmented control in its header. When the control value changes, the cells update to a different UICollectionViewCell class with all new data. It mostly…

Nstandage
- 93
- 5
8
votes
1 answer
Is it possible to create cells with dynamic width but fixed height using Compositional Layout
TLDR;
Depending on the section, I need the cells to be sized either:
Fixed width but dynamic height (for example, full screen width with automatic height depending on the content)
Dynamic width but fixed height (1st cell could be 120pt wide, 2nd…

deniz
- 725
- 10
- 13
7
votes
2 answers
UICollectionViewCompositionalLayout optional sections
I have looked at this question, which is similar: How to deal with empty items section in UICollectionView CompositionalLayout, but the answer there seems to be either leave sections out in the snapshot (which I do, but that leaves another problem,…

ashipma
- 423
- 5
- 15
7
votes
3 answers
Swift: How to Optionally return a header for a collection view section?
I have a UICollectionViewDiffableDataSourcelike so:
var data:UICollectionViewDiffableDataSource!
I define my section header's layout like so:
let header = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize:…

Josh Arnold
- 249
- 4
- 8
7
votes
2 answers
Compositional Layout IOS 13 Group background color
I was trying to find if there is an approach we can use to give background color to a group while using compositional layout. I tried to find a direct API that i can use but didn't find anything.

suraj
- 432
- 5
- 19
7
votes
1 answer
How to create a grid layout with equal row heights using UICollectionViewCompositionalLayout
I've successfully been able to create a grid layout using UICollectionViewCompositionalLayout. However, I am unable to find a clever way of ensuring the UICollectionViewCell in each row in the grid are of the same height when their heights are…

John Slade
- 219
- 1
- 8
6
votes
0 answers
Override LayoutAttributesForElements in UICollectionViewCompositionalLayout to create a Stretchy Header?
Trying to create a stretchy header in Compositional Layout and so far no result, how can I achieve this in a Compositional Layout? Thanks!
Checked all samples I could find and non-talked about UICollectionViewLayoutAttributes in relation to…

Ctan Li
- 177
- 3
- 13
6
votes
3 answers
UICollectionViewCompositionalLayout incorrect item size
I'm currently facing an issue with compositional layout which can also be seen in Apple's example -> ConferenceNewsFeedViewController. The item height is set to .estimated(100) and the width is set to .fractionalWidth(1.0). On the initial display…

Carsten
- 581
- 4
- 17
6
votes
0 answers
UICollectionViewCompositionalLayout's sticky header is jerky
I am trying to use the latest UICollectionViewCompositionalLayout to display paginated data using the UICollectionViewDiffableDataSource . I wanted to show a sticky header above the section that would stay on the top always even while loading the…

Prasad
- 166
- 7
5
votes
1 answer
UICollectionViewCompositionalLayout set contentOffset
I was wondering for a while now, what is the current way (if any) to set contentOffset for a collection view using CompositionalLayout.
I get it that CompositionalLayout built different and each section have it's own embedded scroll view, that's why…

ItayAmza
- 819
- 9
- 21
5
votes
1 answer
Swift Compositional Layout contentInsets.top is not working for header
I'm creating UICollectionViewCompositionalLayout with NSCollectionLayoutSection. I have section with assigned header. Setting contentInsets on section works as expected but setting contentInsets on header works only for horizontal alignment (leading…

MWloczko
- 135
- 2
- 8