MasterOnce

Preview Mode: You are viewing a concept preview. Sign in to start learning and track your progress.

Swift

SwiftUI Text

Text in SwiftUI

What is it?

Text is the simplest SwiftUI view for showing words on the screen. You can change its size, weight, color, and more with modifiers.

Why does it exist?

Every app needs labels, titles, and messages. Text is the foundation for all on-screen messaging in SwiftUI.

Examples

Basic

Example 1

Text("Hello, SwiftUI!")

Shows a line of text on the screen.

Intermediate

Example 1

Text("Profile")
    .font(.title)
    .fontWeight(.bold)

Use font() and fontWeight() modifiers to style the text.

Advanced

Example 1

Text("Score: \(score)")
    .foregroundStyle(.green)
    .padding(8)

Use interpolation to show values and apply color + padding.

Common Mistakes

Common mistakes with Text:
1. Forgetting quotes: Text(Hello) (Error! Must be "Hello")
2. Using UIKit fonts: use .font(.title) not UIFont
3. Putting Text outside a View body: it must be inside a View

Write it once before proceeding

This helps your brain start forming the pattern.

Text("Hello, SwiftUI!")

Text is a label

Simple Explanation

Text is like a label sticker you place on the screen.

Think of it like this

Imagine writing a note and taping it to your monitor. Text is that note.

Tiny Example

Text("Welcome!")  // A simple welcome label

Core Drill: Lock It In

Write the same concept 50 times to make it permanent. Your progress is saved automatically.

Repetitions0 / 50
🔒

Sign In to Unlock

Complete all 50 repetitions and lock this concept in your memory forever.

Ready to Lock This In?

Sign in with Google to start your 50 repetitions and make this concept stick forever.