0Pricing
SwiftUI Academy · Lesson

Displaying Text on Screen

Create and style your first Text view.

Displaying Text on Screen is a free SwiftUI Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the SwiftUI Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Meet the Text View

The Text view is how you put words on screen. It is the simplest, most-used view in all of SwiftUI. ✍️

Your First Text

Create a Text view by passing a string in parentheses. SwiftUI shows exactly what you put inside the quotes.

Text("Hello, SwiftUI!")

Text Lives in the body

You place a Text view inside your view's body, and it appears centered on screen by default.

var body: some View {
    Text("Welcome aboard")
}

Showing a Variable

You can pass a variable instead of a literal. The text updates automatically to match the value you give it.

let name = "Sam"
Text(name)

String Interpolation

Mix values into a string with interpolation using a backslash and parentheses. It is perfect for greetings and counts.

let count = 3
Text("You have \(count) tasks")

Making Text Bigger

Use the font modifier to change size. Apple gives you semantic sizes like title and headline that adapt nicely.

Text("Big News")
    .font(.title)

Bold and Heavy Text

Add weight with the bold modifier to make important words stand out from the rest.

Text("Important")
    .bold()

Coloring Your Text

Change the color with foregroundStyle. Pick a system color like blue or red, or use your own.

Text("On sale")
    .foregroundStyle(.red)

Text Is Smart About Size

A Text view sizes itself to fit its words. It takes only the space it needs, never more, unless you tell it otherwise.

Empty and Long Text

An empty string shows nothing, and very long text wraps onto multiple lines automatically. Text is forgiving by default. 👍

Text Stays Localizable

A plain string literal in Text is treated as a localized key. This makes translating your app later much easier. 🌍

Quick Check

Let's check how you put a custom color on text.

Recap: Displaying Text

The Text view shows strings, variables, and interpolated values. Style it with font, bold, and foregroundStyle, and it sizes itself automatically. 🎉

Frequently asked questions

Is the “Displaying Text on Screen” lesson free?

Yes — the full text of “Displaying Text on Screen” is free to read here on the web, and the SwiftUI Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the SwiftUI Academy course, upgrade to CoddyKit PRO.

What will I learn in “Displaying Text on Screen”?

Create and style your first Text view. You practise SwiftUI Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start SwiftUI Academy?

No prior experience is required. SwiftUI Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Displaying Text on Screen” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this SwiftUI Academy lesson?

Yes. Every SwiftUI Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Is a View?
  2. Displaying Text on Screen
  3. Introducing View Modifiers
  4. Reading the View Hierarchy
← Back to SwiftUI Academy