目次
Advances in UICollectionView
https://developer.apple.com/videos/play/wwdc2020/10097Sessionの概要
強力なCollectionViewの新しい機能について。DiffableデータソースでSectionSnapshotを使用して展開、折りたたみ出来るアウトラインを作成する方法を説明。
また、CollectionViewでTableViewのようなインタフェースを作成するCompositionLayoutでのリストの構築方法の説明。
Cellをdequeueしたりコンテンツとスタイルを構成する最新技術についての説明がされています
Summary
- iOS13から2つのコンポーネントを追加
- Diffable Data Source
- 詳細動画はWWDC 2019 の Advances in UI Data Sources
- Compositional Layout
- 詳細動画はWWDC 2019 の Advances in Collection View Layout
- Diffable Data Source
- iOS14から上記のコンポーネントに新しいAPIが追加
- Diffable Data Source
- Compositional Layout
- Cell Registrations
Section Snapshot
session動画内では下記のように言及されていました目的
Section Snapshots encapsulate the data for a single section in a UICollectionViewSection SnapshotsはUICollectionView内の単一のセクションのデータをカプセル化する
理由
First, to allow data sources to be more composable into section-sized chunks of data.
And second, to allow modeling of hierarchical data, which is needed to support rendering outline-style UIs, a common visual design found all throughout iOS 14.
- データソースをセクションサイズのデータの塊にまとめることができるようにするため
- iOS 14全体に見られる共通のビジュアルデザインであるアウトラインスタイルのUIのレンダリングをサポートするために必要な、階層データのモデリングを可能にすること
Compositional Layout Lists
ポイントは下記で、- UITableView-like sections right into any UICollectionView
- UICollectionViewListCell
- Header / footer support
- Sidebar appearance
Cell Registrations
Cell Registrations are a simple, re-usable way to set up a cell from a view model.ポイントは下記で、
use a generic registration type which incorporates a configuration closure for setting up a new cell from a view model.
- Cellの登録をView ModelからType Safeに行うことが可能
- Cellのコンテンツ設定は軽量かつ簡易に設定可能で、framework側でレイアウトを考慮してパフォーマンスのための自動的な最適化を行う
- 背景設定
- 色やボーダースタイルなどのプロパティ調整が可能