What’s new with UICollectionView in iOS 14
This article covers beta technology and it's up to date for Xcode 12 beta 5
Looking for a great mobile CI/CD solution that has tons of iOS-specific tools, smooth code signing, and even real device testing? Learn more about Bitrise’s iOS specific solutions.
This sponsored message helps keep the content on this site free. Please check out this sponsor as it directly supports me and this site.
This year, the team went all out and shipped even more amazing improvements to
UITableView obsolete through the new
UICollectionLayoutListConfiguration. This new list layout allows you to create collection views that look and function identical to
UITableView. When paired with
UICollectionViewListCell your collection view can support features that used to only be available to
In addition adding features that make collection views look more like table views when needed, the team also made huge improvements to data sources.
Diffable data sources now have first class support for features like reordering and deleting cells. All you have to do is assign a couple of handlers to your data source and the system handles the rest.
As if that's not enough, you can now build collapsable lists in collection views with hardly any effort at all by setting up your diffable data sources with hierarchical data. This is going to save plenty of folks some serious headaches.
If you've worked with diffable data sources before you probably know that they are super convenient. However, every time you want to change a snapshot for your diffable data source in iOS 13 you must recreate or update the entire snapshot. In iOS 14 you can use section snapshots which allow you to only update a specific section in your data source rather than rebuiding the entire snapshot every time.
Apple also made a whole bunch of changes to how we configure collection view cells. Cells can now adopt a new feature that lets developers apply states and configurations to cells to set up their appearance and state. This means that you no longer directly assign values to labels, images or other components of a cell but instead the cell takes a configuration object and updates its UI accordingly. The best part of this feature in my opinion is that these configurations are not tied to collection view cells per se. Any view that can work with these configurations can accept and apply a configuration making this a highly portably and flexible feature.
Last but not least I would like to mention that in iOS 14 there's a new way for developers to register and dequeue their collection view cells. In iOS 13 and earlier you would use a string identifier to register and dequeue cells. In iOS 14 you can do this through the new UICollectionView.CellRegistration and it's truly awesome.
I'm super happy with all of these new collection view features and I can't wait to take them for a spin.
Learn how to use new UICollectionView features
- How to add accessories to a UICollectionViewListCell?
- How to add a custom accessory to a UICollectionViewListCell?
- How to add custom swipe actions to a UICollectionViewListCell?
- Configure collection view cells with UICollectionView.CellRegistration
- How to change a UICollectionViewListCell's separator inset