Replicate the Expandable Date Picker Using UICollectionView List
Replicate the Expandable Date Picker Using UICollectionView List

This article is originally published at https://swiftsenpai.com on January 10, 2021.

The expandable date picker is a very common UI component in the Apple design system. You can find it in the iOS Reminder and Calendar App. Even though it does not come out of the box with UIKit, we can easily create one using a custom cell within a table view.


Adopting it is easy, getting it right is tricky.

The Large Title UINavigationBar Glitches and How to Fix Them
The Large Title UINavigationBar Glitches and How to Fix Them

This article is originally published at https://swiftsenpai.com on December 14, 2020.

Recently I have been requested by my client to add a large title navigation bar into their app’s main screen, on top of that the large title should automatically collapse when users start scrolling.


With a simple approach recommended by the Apple engineers

Reducing Memory Footprint When Using UIImage
Reducing Memory Footprint When Using UIImage

This article is originally published at https://swiftsenpai.com on December 1, 2020.

Recently my team and I are working on an image processing app for a client. The app works pretty well on most of the aspects. Unfortunately, when we start loading HD images on screen, the app will crash occasionally due to “out of memory exception”.

In this article, I would like to share with you the problem we are facing, what is the root cause of the high memory usage and how we manage to reduce the app’s memory footprint using a simple fix recommended by the Apple engineers.

The Problem

As mentioned earlier, our app’s memory usage spikes up pretty high when we start loading HD images on screen. …


Using built-in and custom text provider

Image for post
Image for post

This article is originally published at https://swiftsenpai.com on November 15, 2020.

It’s been awhile since I covered topics related to Lottie animation. In my previous article, “ Modifying Lottie Animation with Value Providers “, I have discussed how developers can leverage different kinds of value providers to manipulate an animation during runtime based on their own needs.

In this article, let’s take a look at another less known yet pretty useful value provider in the Lottie SDK — Text Provider. As you might have guessed, a text provider allows you to change the texts within a Lottie animation during runtime.

Wanted to know more? …


A declarative way to add a custom header

Image for post
Image for post

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


No storyboard or interface builder required.

Declarative UICollectionView List Header and Footer
Declarative UICollectionView List Header and Footer

This article is originally published at https://swiftsenpai.com on October 19, 2020.

If you have been following my work for the past couple of months, you have probably read my articles about constructing a basic and expandable list declaratively using cell registration, content configuration, and data source snapshot.

In this article, let’s take one step further and learn how you can construct a list with header and footer declaratively without the need of using storyboard or interface builder.

For simplicity’s sake, this article will only be focusing on configuring and adding a system default header and footer, ways to add a custom header and footer will be a story for another day. …


It might not be as straightforward as you think.

The Modern Ways to Reload Your Table and Collection View Cells
The Modern Ways to Reload Your Table and Collection View Cells

This article is originally published at https://swiftsenpai.com on October 4, 2020.

In iOS 13, Apple introduced diffable data source and snapshot, defining the modern era of table view and collection view. Prior to this, reloading a table or collection view cell can be easily done by calling one of the following functions:

reloadRows(at:with:) // For reloading table view cell reloadItems(at:) // For reloading collection view cell

For table and collection views constructed using a diffable data source, this is no longer true. If so, how should developers go about reloading their table and collection view cells?

The solution to this might not be as straightforward as you think. Due to the difference between value type and reference type, there will be 2 different ways to reload the table and collection view cells. …


It’s never been so easy!

Image for post
Image for post

This article is originally published at https://swiftsenpai.com on September 22, 2020.

In last week’s article, we learned how to leverage the NSDiffableDataSourceSectionSnapshot to create an expandable list in a single-section collection view. In this article, we will pick up where we left off by modifying last week's sample app to display the same set of model objects in a multi-section collection view.

Following animated GIF showcases what we going to build in this article.


It’s never been so easy!

Building an Expandable List Using UICollectionView
Building an Expandable List Using UICollectionView

This article is originally published at https://swiftsenpai.com on September 10, 2020.

Expandable list or some might call it expandable table view, is a very common UI design that is used in a large variety of apps. Despite the fact that it is so popular, UIKit does not have any native APIs that support this kind of layout.

With the introduction of iOS 14, this is no longer true!

According to Apple, developers can now easily create an expandable list by using the new UICollectionView list layout APIs. …


Learn how to set a custom cell height as well.

Designing Custom UICollectionViewListCell in Interface Builder
Designing Custom UICollectionViewListCell in Interface Builder

This article is originally published at https://swiftsenpai.com on August 22, 2020

Since the publishing of my article “UICollectionView List with Custom Cell and Custom Configuration”, a lot of my readers have been asking me whether it is possible to design the custom UICollectionViewListCell in the interface builder.

Well, the answer is definitely yes!

Since the UICollectionViewListCell's content view is just a UIView subclass that conforms to the UIContentView protocol, theoretically as long as we are able to link up the content view with the interface builder then everything should work accordingly.

After spending some time experimenting in Xcode, I have successfully created a UICollectionViewListCell content view using interface builder. On top of that, I also discovered that you can even manipulate the cell height by adjusting the auto layout constraints within the cell's content view. …

About

Lee Kah Seng

https://swiftsenpai.com | iOS developer since 2011 | Swift Lover | Music Addict | Anime Fan | Part-time Backpacker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store