UICollectionView List with Interactive Custom Header
A declarative way to add a custom header
This article is originally published at https://swiftsenpai.com on November 7, 2020.
In my previous article, we had discussed how to add a declarative header and footer to the UICollectionView
List. This week, let's take one step further and talk about how you can add a custom header to your collection view declaratively.
This is a continuation of my previous article “ Declarative UICollectionView List Header and Footer “, therefore do make sure to check it out before proceeding.
The Sample App
To keep things as simple as possible, we will create a simple custom header that consists of a title label and an info button. When tap on the info button, the app will display an alert showing detailed information about that particular section.
Creating the Custom Header
First things first, let’s create the custom header by subclassing the UICollectionReusableView
.