Reputation: 13073
Based on filter results, I need to change the flow layout of a collection view and reload the data using a different kind of cell. However you can't just do this:
myCollectionView.flowLayout = ...
So how is it possible to change the flow layout of a collection view?
Upvotes: 3
Views: 11542
Reputation: 534893
SHORT AND SIMPLE ANSWER
You can access/set the flowLayout like this:
collectionView.collectionViewLayout = ...
LONG ANSWER
You said:
However you can't just do this:
myCollectionView.flowLayout = ...
But in fact you can set the collection view’s collectionViewLayout
, and it does just what you want:
Assigning a new layout object to this property causes the new layout to be applied ... to the collection view’s items.
Upvotes: 9