0Pricing
SwiftUI Academy · Lektion

Tastaturtypen und Platzhalter

Konfigurieren Sie Tastatur, Eingabeaufforderung und Submit-Verhalten.

Tastaturtypen und Platzhalter 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.

Shape the Input

A bare TextField accepts anything. With a few modifiers you can shape the keyboard, the hint, and what happens on submit. ⌨️

Choosing a Keyboard

The keyboardType modifier picks which on-screen keyboard appears. An email field deserves the email layout, not the full alphabet.

TextField("Email", text: $email)
  .keyboardType(.emailAddress)

Numbers Only

Asking for a phone or amount? Use .numberPad or .decimalPad so users get a clean number keyboard with no letters in the way.

TextField("Age", text: $age)
  .keyboardType(.numberPad)

Placeholder vs Prompt

The first string argument is the placeholder, the gray hint shown while the field is empty. It guides users without taking up extra space.

TextField("Search recipes", text: $query)

A Separate Prompt

You can also pass a prompt as its own argument. This keeps the visible label and the placeholder hint as two distinct pieces of text.

TextField("City", text: $city,
  prompt: Text("e.g. Tokyo"))

Capitalization Control

Use textInputAutocapitalization to decide how the keyboard capitalizes. Set it to .never for usernames so nothing is auto-uppercased.

TextField("Username", text: $user)
  .textInputAutocapitalization(.never)

Turning Off Autocorrect

For codes, handles, or URLs, autocorrect gets in the way. Add autocorrectionDisabled to let users type exactly what they mean.

TextField("Handle", text: $handle)
  .autocorrectionDisabled()

The Return Key Label

The submitLabel modifier changes the keyboard return key text. Use .search, .done, or .next to match what the field actually does.

TextField("Search", text: $query)
  .submitLabel(.search)

Reacting to Submit

The onSubmit modifier runs your code when the user taps return. It is the perfect place to start a search or move focus.

TextField("Search", text: $query)
  .onSubmit { runSearch() }

Stack the Modifiers

These modifiers chain freely. Combine keyboard type, capitalization, and submit label on one field to craft exactly the input you want.

Small Details, Big Polish

The right keyboard and a clear prompt feel effortless to users. These tiny touches are what make an app feel professional. ✨

Quick Check

Which modifier changes the keyboard that appears for a TextField?

Recap

You tuned a field with keyboardType, prompts, capitalization, and onSubmit. Small modifiers turn a plain box into thoughtful, friendly input. 🎉

Häufig gestellte Fragen

Ist die Lektion „Tastaturtypen und Platzhalter“ kostenlos?

Ja — der vollständige Text von „Tastaturtypen und Platzhalter“ 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 „Tastaturtypen und Platzhalter“?

Konfigurieren Sie Tastatur, Eingabeaufforderung und Submit-Verhalten. 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 „Tastaturtypen und Platzhalter“?

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

  1. Ein TextField an State binden
  2. Tastaturtypen und Platzhalter
  3. SecureField für Passwörter
  4. Live-Eingabevalidierung
← Zurück zu SwiftUI Academy