0Pricing
SwiftUI Academy · درس

أنواع لوحة المفاتيح والعناصر النائبة

اضبط لوحة المفاتيح والتلميح وسلوك الإرسال

أنواع لوحة المفاتيح والعناصر النائبة درس مجاني في SwiftUI Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في SwiftUI Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة SwiftUI Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

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

الأسئلة الشائعة

هل درس «أنواع لوحة المفاتيح والعناصر النائبة» مجاني؟

نعم — نص درس «أنواع لوحة المفاتيح والعناصر النائبة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة SwiftUI Academy، انتقل إلى CoddyKit PRO. تتضمن دورة SwiftUI Academy 4 دروس في المجموع.

ماذا ستتعلم في «أنواع لوحة المفاتيح والعناصر النائبة»؟

اضبط لوحة المفاتيح والتلميح وسلوك الإرسال تتمرن على SwiftUI Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ SwiftUI Academy؟

لا تُشترط خبرة سابقة. SwiftUI Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «أنواع لوحة المفاتيح والعناصر النائبة»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس SwiftUI Academy هذا؟

نعم. كل درس في SwiftUI Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. ربط TextField بالحالة
  2. أنواع لوحة المفاتيح والعناصر النائبة
  3. SecureField لكلمات المرور
  4. التحقق المباشر من الإدخال
← العودة إلى SwiftUI Academy