Create a UICollectionView programmatically
Wholly programatically?
Before we start
Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 12.5, and Swift 5.4
Prerequisites:
- You will be expected to be aware how to make a Single View Application in Swift.
Terminology
Subclassing: This is the act of basing a new class on an existing class
UICollectionView: An object that manages an ordered collection of data items and presents them using customizable layouts
The project
This article will run through creating a UICollectionView
programatically, with one version using aUICollectionViewCell
and one using a subclassed UICollectionViewCell
called SubclassedCollectionViewCell
.
A Menu
This isn’t entirely part of this guide, however we will still look into the working of the menu (or at least have the code here!).
The menu will help the user choose between a view controller using the standard UICollectionViewCell
, and one that uses a…