Questions tagged [uicollectionviewlayout]

The UICollectionViewLayout class is an abstract base class that is used to generate layout information for a collection view.

The UICollectionViewLayout class is an abstract base class that you subclass and use to generate layout information for a collection view. The job of a layout object is to determine the placement of cells, supplementary views, and decoration views inside the collection view’s bounds and to report that information to the collection view when asked. The collection view then applies the provided layout information to the corresponding views so that they can be presented onscreen.

More: UICollectionViewLayout Class Reference

1496 questions
12
votes
2 answers

Custom UICollectionViewFlowLayout animation

I've got a custom UICollectionViewFlowLayout animation that staggers views in from the right with insertions and out to the left with deletions. It does it by setting a CABasicAnimation on the UICollectionViewLayoutAttributes and applying this to…
bandejapaisa
  • 26,576
  • 13
  • 94
  • 112
12
votes
3 answers

How to subclass UICollectionViewLayoutAttributes

I am trying to subclass UICollectionViewLayoutAttributes so that I can add an extra attribute points (an array of CGPoints). The subclass is designed to only be used as attributes for decoration views so I need to set the member…
11
votes
4 answers

How hide header on iOS 13 Collection View Compositional Layout

I encounter a wonder point when deploy the iOS 13 Compositional Layout. I want to hide collection view header and implement referenceSizeForHeaderInSection method, however the referenceSizeForHeaderInSection can not work on Compositional Layout This…
Joshpy
  • 560
  • 8
  • 21
11
votes
2 answers

How to apply different contentInset only for contents cells but not for a header in UICollectionView

I use insetForSectionAtIndex method to set contentInset for a section in my collection view and I don't want to apply that inset to a header of the section. I need the header width to be as wide as the screen. ConentInset func…
Bigair
  • 1,452
  • 3
  • 15
  • 42
11
votes
1 answer

Proper way to invalidate collection view layout upon size change

I'm implementing a collection view whose items are sized based on the bounds of the collection view. Therefore when the size changes, due to rotating the device for example, I need to invalidate the layout so that the cells are resized to consider…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
11
votes
1 answer

CSStickyHeaderFlowLayout Header Frame

EDIT: I have create a very small app that represents perfectly the problem. https://drive.google.com/file/d/0B6sI4Feh1HJUb3pGa2pBUmY4QW8/view?usp=sharing In the sample app, we just need to scroll down then press the button on the top bar to see the…
11
votes
1 answer

UICollectionViewLayout layoutAttributesForElementsInRect and layoutAttributesForItemAtIndexPath

I'm implementing a custom flow layout. It has 2 main methods for overriding to determine placement of cells: layoutAttributesForElementsInRect and layoutAttributesForItemAtIndexPath. In my code, layoutAttributesForElementsInRect is called, but…
11
votes
1 answer

How to interpolate custom UICollectionViewLayoutAttributes properties with UICollectionViewTransitionLayout

I have two custom UICollectionViewLayout objects that use a custom UICollectionViewLayoutAttributes subclass. These custom attributes add a single property tintAlpha that controls the opacity of a tint overlay view attached to each collection view…
Stuart
  • 36,683
  • 19
  • 101
  • 139
11
votes
6 answers

Customising position of header in UICollectionView layout causes NSInternalInconsistencyException error

I am trying to customise the positions of the headers in a UICollectionView using a subclassed UICollectionViewFlowLayout class (based loosely on the code for stacked headers which is shown enter link description here). As a minimal test, let's say…
Ken Chatfield
  • 3,277
  • 3
  • 22
  • 27
11
votes
1 answer

Using [UICollectionView performBatchUpdates:] with a UICollectionViewFlowLayout that has UIDynamics

Okay so basic overview. I have a UICollectionView that I needs to support adding and removing item through the performBatchUpdates: method. If I use a standard UICollectionViewFlowLayout, it works fine. However, when I try to use a…
11
votes
3 answers

iOS UICollectionView - default flow, fill rows from right to left

I'm using in one of my apps UICollectionView, with custom cells but with default flow. Currently this view shows 3 cells in a row (all of them the same size). The cells fill the row from left to right, but I need it from right to left. Is it…
Asaf
  • 2,158
  • 2
  • 25
  • 40
11
votes
2 answers

UICollectionView interactive layout transition using iOS 7 APIs

I'm trying to get a handle on new iOS 7 APIs that allow for interactive, animated view controller transitions, including transitions between UICollectionViewLayouts. I've taken and modified sample code from WWDC 2013, "iOS-CollectionViewTransition",…
Tim Arnold
  • 8,359
  • 8
  • 44
  • 67
11
votes
1 answer

How can I set the entire header view to UICollectionView?

I want to set the header to collection view, just like UITableViewController's setTableHeader does. I found the way to set the each section's header on collection view, but I couldn't find how to set the header view of the entire header. Apple's…
glast
  • 383
  • 1
  • 4
  • 17
10
votes
1 answer

Changing UICollectionView layout depending on section

I am currently implementing a UICollectionView with several sections (let's say 4) like in the image below: From section 0 to section 2 it is just a UICollectionViewFlowLayout with different cell sizes for each section but for section 3, it is a…
Florian Ldt
  • 1,125
  • 3
  • 13
  • 31
10
votes
5 answers

Cell size not updating after changing flow layout's itemSize

In my app, I have a full-screen paging collection view and each cell needs to be full-screen as well, so the collection view layout's item size needs to be the same size as the view controller's view's bounds size. To do this, in…
Jordan H
  • 52,571
  • 37
  • 201
  • 351