0Pricing
SwiftUI Academy · Lezione

Visualizzare testo sullo schermo

Creare e applicare uno stile alla prima view Text.

Visualizzare testo sullo schermo è una lezione SwiftUI Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento SwiftUI Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso SwiftUI Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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. 🎉

Domande Frequenti

La lezione «Visualizzare testo sullo schermo» è gratuita?

Sì — il testo completo di «Visualizzare testo sullo schermo» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso SwiftUI Academy, passa a CoddyKit PRO. Il corso SwiftUI Academy include 4 lezioni in totale.

Cosa imparerò in «Visualizzare testo sullo schermo»?

Creare e applicare uno stile alla prima view Text. Eserciti SwiftUI Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare SwiftUI Academy?

Non è richiesta alcuna esperienza precedente. SwiftUI Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.

Quanto tempo richiede la lezione «Visualizzare testo sullo schermo»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione SwiftUI Academy?

Sì. Ogni lezione SwiftUI Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Che cos'è una View?
  2. Visualizzare testo sullo schermo
  3. Introduzione ai modificatori delle view
  4. Leggere la gerarchia delle view
← Torna a SwiftUI Academy