0Pricing
SwiftUI Academy · درس

التعريف بمعدِّلات View

سلسِل المعدِّلات لتغيير المظهر والسلوك

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

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

What Is a Modifier?

A view modifier tweaks how a view looks or behaves. You attach one with a dot right after the view. 🎨

Text("Styled")
    .font(.title)

Modifiers Return a New View

Each modifier wraps the view and returns a new view. The original is never changed; you always get a styled copy back.

Chaining Modifiers

You can stack modifiers one after another. This is called chaining, and each line adds another layer of styling.

Text("Hi")
    .font(.title)
    .bold()
    .foregroundStyle(.blue)

Adding Padding

The padding modifier adds breathing room around a view. It is one of the most common modifiers you will use.

Text("Spaced out")
    .padding()

Adding a Background

Use background to place a color or view behind your content. Pair it with padding for a clean card look.

Text("Card")
    .padding()
    .background(.yellow)

Order Matters

Modifiers apply top to bottom, so their order changes the result. Padding before background colors a different area than after.

See Order in Action

Here background comes first, so only the original text gets color, then padding adds clear space outside it. 🔄

Text("Try it")
    .background(.green)
    .padding()

Rounding Corners

After a background, the cornerRadius modifier rounds the edges to give views a soft, modern feel.

Text("Pill")
    .padding()
    .background(.blue)
    .cornerRadius(12)

Modifiers Work on Any View

Modifiers are not just for Text. Any view, including images and stacks, can be styled the same way.

Reading a Modifier Chain

Read a chain like a recipe from top to bottom. Each step builds on the result of the step above it.

Keep Chains Readable

Put each modifier on its own line. This keeps long chains readable and makes it easy to add or remove a step later. ✨

Quick Check

Let's test how a modifier affects the view it is attached to.

Recap: View Modifiers

Modifiers attach with a dot, return new views, and chain top to bottom where order matters. Use padding, background, and cornerRadius to style anything. 🎉

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

هل درس «التعريف بمعدِّلات View» مجاني؟

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

ماذا ستتعلم في «التعريف بمعدِّلات View»؟

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

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

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

كم من الوقت يستغرق درس «التعريف بمعدِّلات View»؟

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

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

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

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

  1. ما هي View؟
  2. عرض النص على الشاشة
  3. التعريف بمعدِّلات View
  4. قراءة تسلسل View الهرمي
← العودة إلى SwiftUI Academy