Swiftmas – Day 02 – Cards

Posted by

·

Who else loves Christmas Cards!

For the Second prompt, we have Cards. What will you create?

I’m looking forward to seeing what you come up with today.

Let’s make a Greeting Card Creator App

In this tutorial, we’ll build a Greeting Card Creator app using SwiftUI. The app allows users to personalize a digital greeting card by:

  1. Adding the recipient’s name and a custom message.
  2. Selecting from multiple festive card backgrounds.
  3. Displaying the final card with a polished and cheerful UI.

Let’s bring this idea to life!

Getting Started


1. Create a New SwiftUI Project

You can find the sample project in the GitHub repository here

  1. Open Xcode and create a new project using the App template.
  2. Name the project (e.g., “GreetingCardApp”), and ensure the interface is set to SwiftUI.
  3. Click Create to initialize the project.

For ease of finding all the image I have used, I’m placing all the pixabay links below & of course they will be included in the sample project. The background I personally made in Affinity Designer & can be download just below too.

Card Background 1Card Background 2 Card Background 3Card Background 4


Step 1: Building the Greeting Card View

The centerpiece of the app is the customizable greeting card. Start by creating a ZStack to display:

  1. A background image for the card.
  2. The recipient’s name and message on top.

Here’s the code:

This code dynamically updates the background image and text as the user inputs new details.


Step 2: Adding User Inputs

Recipient Name Field

To personalize the card, add a TextField for the recipient’s name:

Message Field

Similarly, add another TextField for the greeting message:

These fields allow users to input a name and a custom message, which will immediately update on the card.


Step 3: Switching Card Backgrounds

Let’s give users the ability to select a card background. We’ll create a VStack with buttons representing different card themes:

Each button calls a simple function to update the backgroundTheme variable, instantly changing the card background.


Reusable Background Thumbnail

For the buttons, we use a reusable cardModifier view to display scaled-down previews of the card backgrounds:


Step 4: Add a Festive Background

Let’s complete the app by adding a festive background that spans the entire screen. Wrap the VStack with a ZStack:

Add a holiday-themed image (e.g., candy canes or snowflakes) to your project’s assets and name it "candybg". This background enhances the app’s visual appeal.


The Complete Code

Here’s the entire app, ready to run:


Run Your App

  1. Add images (card-1card-2, etc., and candybg) to your asset catalog.
  2. Run the app in the simulator or on a device.
  3. Customize your greeting card and enjoy!

Enhancements to Try

  1. Save and Share: Allow users to export the card as an image or share it.
  2. Animations: Add subtle animations when switching backgrounds or updating the text.
  3. Themes: Add more backgrounds and let users select a font style.

With this app, you’re one step closer to spreading festive joy. Happy coding! 🎉


Discover more from

Subscribe to get the latest posts sent to your email.

thecodingsprite avatar

About the author

Hi! My name is Billie, my friends call me Billie Boo. I am a self taught iOS developer with a background in computer science, animation, graphic design & web design. I love sharing my knowledge & projects with the world & that is my mission for this blog. It’s never too late or too hard to follow your dreams.