Mostrar texto en pantalla
Cree y personalice su primera vista Text.
Mostrar texto en pantalla es una lección gratuita de SwiftUI Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de SwiftUI Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de SwiftUI Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en 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. 🎉
Aprende Swift con un tutor de IA — gratis
Escribe y ejecuta código real en tu navegador, obtén ayuda instantánea de un tutor de IA disponible 24/7 y continúa donde lo dejaste en la web o en la aplicación.
- Cursos
- 30
- Lecciones
- 120
Preguntas frecuentes
¿La lección «Mostrar texto en pantalla» es gratis?
Sí — el texto completo de «Mostrar texto en pantalla» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de SwiftUI Academy, actualiza a CoddyKit PRO. El curso de SwiftUI Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Mostrar texto en pantalla»?
Cree y personalice su primera vista Text. Practicas SwiftUI Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar SwiftUI Academy?
No se requiere experiencia previa. SwiftUI Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Mostrar texto en pantalla»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de SwiftUI Academy?
Sí. Cada lección de SwiftUI Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- ¿Qué es una View?
- Mostrar texto en pantalla
- Introducción a los modificadores de vistas
- Lectura de la jerarquía de vistas