0Pricing
SwiftUI Academy · درس

ما هي View؟

تعلّم بروتوكول View والخاصية المحسوبة body

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

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

Everything Is a View

In SwiftUI, almost everything you see on screen is a view. Text, images, buttons, and even your whole screen are all views. 📱

The View Protocol

A view is any type that conforms to the View protocol. Conforming means you promise to describe what should appear on screen.

struct ContentView: View {
    var body: some View {
        Text("Hello!")
    }
}

Views Are Structs

Most SwiftUI views are simple structs. They are lightweight value types, so SwiftUI can create and discard them cheaply as your UI changes.

The body Requirement

The View protocol has one job for you: provide a body property. It is where you describe the view's content.

struct ContentView: View {
    var body: some View {
        Text("Welcome")
    }
}

body Is Computed

The body is a computed property, not stored. SwiftUI reads it whenever it needs to redraw, so it always reflects your latest code.

What some View Means

The return type some View says body returns one specific view type, but you do not have to spell out which. The compiler figures it out.

var body: some View {
    Text("Opaque type magic")
}

One View, Many Pieces

A single view's body often combines many smaller views. The whole arrangement is still treated as one view from the outside. 🧩

Views Describe, Not Draw

You never paint pixels yourself. A view simply describes what it wants, and SwiftUI decides how to render it efficiently.

Views Are Cheap and Disposable

Because views are value types, SwiftUI recreates them constantly. Do not store heavy work in a view; keep its body fast and simple.

Composing Custom Views

You build your app by writing your own custom views. Each one is a struct conforming to View, just like the built-in ones.

struct GreetingView: View {
    var body: some View {
        Text("Hi there")
    }
}

Reusing Your Views

Once you define a view, you can drop it anywhere just by its name. This reuse keeps your UI consistent and your code tidy.

var body: some View {
    GreetingView()
}

Quick Check

Let's confirm what makes a type a SwiftUI view.

Recap: What Is a View?

A view is a struct that conforms to View and provides a body of type some View. Views describe content, are cheap, and compose into your whole UI. 🎉

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

هل درس «ما هي View؟» مجاني؟

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

ماذا ستتعلم في «ما هي View؟»؟

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

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

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

كم من الوقت يستغرق درس «ما هي View؟»؟

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

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

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

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

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