Member-only story

How to Create Multiple Themes in a SwiftUI Application

A quick tutorial to customize and apply your own themes in iOS

Pavlos Simas
Better Programming
Published in
3 min readJan 9, 2022
Source: Undraw

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:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Pavlos Simas
Pavlos Simas

Written by Pavlos Simas

iOS Developer, with passion about Development, Marketing and Finance. Join Medium from the following link: https://simaspavlos.medium.com/membership

Responses (2)

Write a response