UICollectionView 上級編

Advances in UICollectionView

https://developer.apple.com/videos/play/wwdc2020/10097

Sessionの概要

強力なCollectionViewの新しい機能について。
DiffableデータソースでSectionSnapshotを使用して展開、折りたたみ出来るアウトラインを作成する方法を説明。
また、CollectionViewでTableViewのようなインタフェースを作成するCompositionLayoutでのリストの構築方法の説明。
Cellをdequeueしたりコンテンツとスタイルを構成する最新技術についての説明がされています

Summary

Section Snapshot

session動画内では下記のように言及されていました

目的

Section Snapshots encapsulate the data for a single section in a UICollectionView

Section 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のレンダリングをサポートするために必要な、階層データのモデリングを可能にすること
詳細についてはAdvances in Diffable Data Sourcesの記事を参照してください

Compositional Layout Lists

ポイントは下記で、
  • UITableView-like sections right into any UICollectionView
  • UICollectionViewListCell
  • Header / footer support
  • Sidebar appearance
sidebarの表示はiPadOS向け 詳細についてはLists in UICollectionViewの記事を参照してください

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側でレイアウトを考慮してパフォーマンスのための自動的な最適化を行う
  • 背景設定
    • 色やボーダースタイルなどのプロパティ調整が可能
詳細についてはModern Cell Configurationの記事を参照してください
最新情報をチェックしよう!