Skip to content

UICollectionViewCompositionalLayout ​

UICollectionViewCompositionalLayout represents a compositional layout: a layout object built from sections, groups, and items. For now it can only build list layouts: pass a UICollectionLayoutListConfiguration to layoutWithListConfiguration(), and pass the resulting layout to new UICollectionView().

Inheritance: EventTarget → NSObject → UICollectionViewLayout → UICollectionViewCompositionalLayout

Constructor ​

It can't be created with new; new UICollectionViewCompositionalLayout() throws TypeError. Use the static method below.

Static methods ​

UICollectionViewCompositionalLayout.layoutWithListConfiguration()

Creates a list layout from a list configuration.

Examples ​

js
const layout = UICollectionViewCompositionalLayout.layoutWithListConfiguration(
  new UICollectionLayoutListConfiguration('insetGrouped'));
const list = new UICollectionView(layout);
console.log(list.collectionViewLayout === layout);

Result: You get a list with a rounded-card look. The console prints true.

Corresponding iOS API ​

ObjCJS
[UICollectionViewCompositionalLayout layoutWithListConfiguration:config]UICollectionViewCompositionalLayout.layoutWithListConfiguration(config)

See also ​