Practical Introduction to Custom UICollectionView Layouts

There is a massive number of iOS applications available on the App Store these days, and every single one of them looks different.

Despite that, there’s one thing that most applications have in common: lists. From the early days, iOS developers had access to the famous UITableView and used it a lot. The UITableView, however has some major limitations. It has to be vertical, and there’s not a lot you can customise about its layout.

Luckily, in iOS 6, UICollectionView came to the rescue and addressed both problems mentioned above. In this blogpost, I want to show how we can benefit from customising the UICollectionViewLayout. Apart from a theoretical introduction that I’ve seen so many times on so many blogs, I will also share the problems I would like to solve and entire solutions for resolving them. In order not to make this too overwhelming, I’ll start with simple things and move up to the more advanced aspects step by step. Everything you will see here you can also download from GitHub, split into nice and easy-to-understand modules – see the link at the end. I know that there's some force unwrapping and code repetitions. I’ve included them on purpose in order to make the code easier to read and understand. This introduction is already too long, so, without further ado, let’s dive into the beautiful world of customising the UICollectionView layouts!

Michał Kwiecień

Michał is an enthusiast of Apple devices and software. He tries to wake up early every single day and… he fails every single day. He loves the Getting Things Done method and ticking off tasks from his to-do list.

We're Netguru

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency.

Let's talk business