تنسيق الأزرار
طبّق أنماط الأزرار المضمّنة ومظهراً مخصصاً
تنسيق الأزرار درس مجاني في SwiftUI Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في SwiftUI Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة SwiftUI Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Default Looks Are Fine
SwiftUI gives every button a sensible default style for the platform. But you can reshape its look in seconds with a single modifier. 🎨
The buttonStyle Modifier
Apply a built-in look with the buttonStyle modifier. It changes the whole appearance without you touching the label or action.
Button("Save") { save() }
.buttonStyle(.bordered)Bordered for Soft Buttons
The .bordered style draws a soft, tinted capsule around your label. It is great for secondary actions that should look calm.
Button("Cancel") { dismiss() }
.buttonStyle(.bordered)Prominent for the Main Action
Use .borderedProminent to make the primary action pop with a filled background. Reserve it for the one button that matters most.
Button("Continue") { next() }
.buttonStyle(.borderedProminent)Tinting a Button
Set the accent color of a styled button with the tint modifier. It changes the fill or border to match your brand.
Button("Delete") { remove() }
.buttonStyle(.borderedProminent)
.tint(.red)Controlling Size
The controlSize modifier scales a button between mini, small, regular, and large, so it fits the importance of the action.
Button("Go") { go() }
.buttonStyle(.bordered)
.controlSize(.large)Rounding the Corners
Want a different shape? Pair a style with buttonBorderShape to switch between capsule, rounded rectangle, and more.
Button("Join") { join() }
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)Styling the Label Yourself
For full control, style the label view directly with padding, background, and color, just like any other SwiftUI view.
Button("Buy") { buy() }
.padding()
.background(.blue)
.foregroundStyle(.white)Order of Modifiers
Modifier order matters. Padding before background gives roomy color; background before padding leaves an outer margin instead.
Plain and Borderless
For a text-only look with no chrome, reach for the .plain style. It strips decoration so only your label shows.
Button("Skip") { skip() }
.buttonStyle(.plain)Keep It Consistent
Pick a few styles and reuse them across your app. Consistency helps people instantly know what is tappable and what is primary.
Quick Check
Time to test your styling instincts.
Recap
Great job! Use buttonStyle for built-in looks, tint and controlSize to refine them, or style the label directly for full control. 🎨
الأسئلة الشائعة
هل درس «تنسيق الأزرار» مجاني؟
نعم — نص درس «تنسيق الأزرار» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.