Member-only story
How to Create Multiple Themes in a SwiftUI Application
A quick tutorial to customize and apply your own themes in iOS

In this tutorial, we will see how to create multiple themes for our app written in SwiftUI.
We will use a simple example with just a Text
that changes color and text based on the Theme
.
Setup Project
Create a new project and check SwiftUI for your view. We need to create 4 new files for our tutorial.
Let’s call them ThemeManager
, Theme
, BlueTheme
, and RedTheme
. Your file explorer should look like this:

Leave the View
as it is with the “Hello World” text. We will change it later.
Now let’s see with this technique how to create a new Theme
.
First, we need a protocol that all our themes will implement. We called that protocol Theme
. This is how this file should look like: