SwiftUI Academy · Aula

Exibindo texto na tela

Crie e estilize sua primeira visualização Text.

Aula 2 de 413 etapas

Exibindo texto na tela é uma aula grátis de SwiftUI Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de SwiftUI Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de SwiftUI Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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

Grátis para começar

Aprenda Swift com um tutor de IA — grátis

Escreva e execute código real no seu navegador, obtenha ajuda instantânea de um tutor de IA 24/7 e continue de onde parou na web ou no app.

Cursos
30
Aulas
120

Perguntas Frequentes

A aula “Exibindo texto na tela” é grátis?

Sim — o texto completo de “Exibindo texto na tela” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de SwiftUI Academy, atualize para CoddyKit PRO. O curso de SwiftUI Academy inclui 4 aulas no total.

O que vou aprender em “Exibindo texto na tela”?

Crie e estilize sua primeira visualização Text. Você pratica SwiftUI Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar SwiftUI Academy?

Nenhuma experiência prévia é necessária. SwiftUI Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Exibindo texto na tela”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de SwiftUI Academy?

Sim. Cada aula de SwiftUI Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. O que é uma visualização?
  2. Exibindo texto na tela
  3. Apresentando os modificadores de visualização
  4. Lendo a hierarquia de visualizações
← Voltar para SwiftUI Academy