Text auf dem Bildschirm anzeigen
Erstellen und gestalten Sie Ihre erste Text-View.
Text auf dem Bildschirm anzeigen ist eine kostenlose SwiftUI Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des SwiftUI Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der SwiftUI Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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. 🎉
Häufig gestellte Fragen
Ist die Lektion „Text auf dem Bildschirm anzeigen“ kostenlos?
Ja — der vollständige Text von „Text auf dem Bildschirm anzeigen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des SwiftUI Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der SwiftUI Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Text auf dem Bildschirm anzeigen“?
Erstellen und gestalten Sie Ihre erste Text-View. Du übst SwiftUI Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um SwiftUI Academy zu starten?
Keine Vorkenntnisse erforderlich. SwiftUI Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.
Wie lange dauert die Lektion „Text auf dem Bildschirm anzeigen“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser SwiftUI Academy-Lektion Code schreiben und ausführen?
Ja. Jede SwiftUI Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Was ist eine View?
- Text auf dem Bildschirm anzeigen
- View-Modifier kennenlernen
- Die View-Hierarchie lesen