0Pricing
SwiftUI Academy · Lektion

Kontur, Füllung und overlay

Umranden und füllen Sie Formen für Badges und Karten.

Kontur, Füllung und overlay ist eine kostenlose SwiftUI Academy-Lektion auf CoddyKit. Dies ist Lektion 4 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.

Fill vs Stroke

A shape can be painted inside with fill or outlined with stroke. Together they let you build badges and cards.

Filling a Shape

Use fill to paint the whole inside of a shape with a color or gradient. It is the most common way to color a shape. 🎨

Circle()
    .fill(.blue)

Outlining with stroke

The stroke modifier draws only the border of a shape, leaving the center empty. Perfect for hollow rings and outlines.

Circle()
    .stroke(.blue)

Controlling Line Width

Pass a lineWidth to stroke to make the outline thicker or thinner. A larger number gives a bolder border.

Circle()
    .stroke(.blue, lineWidth: 4)

Dashed Borders

Use a StrokeStyle with a dash pattern for dashed outlines. Great for placeholders and drop zones in your UI.

RoundedRectangle(cornerRadius: 12)
    .stroke(style: StrokeStyle(lineWidth: 2, dash: [6]))

Fill and Stroke Together

Want both a fill and a border? Use fill with a stroke argument to paint inside and outline in one call.

Circle()
    .fill(.yellow)
    .stroke(.orange, lineWidth: 3)

Meet the overlay

The overlay modifier layers a view on top of another. Use it to add a border, badge, or icon over existing content.

Borders via overlay

A classic trick: fill a shape, then add a stroked copy with overlay. You get a clean filled card with a crisp border.

RoundedRectangle(cornerRadius: 12)
    .fill(.white)
    .overlay(
        RoundedRectangle(cornerRadius: 12)
            .stroke(.gray, lineWidth: 1))

Overlaying an Icon

You can overlay any view, not just shapes. Drop a small badge or icon onto a card to highlight new or important items.

Circle()
    .fill(.blue)
    .overlay(Text("3").foregroundStyle(.white))

overlay vs background

Remember the layers: overlay sits on top of a view, while background sits behind it. Pick by which side you want the decoration.

Building a Badge

Combine fill, stroke, and overlay to craft polished badges, avatars, and cards. These three tools cover most decoration. ✨

Quick Check

You want to layer a stroked border on top of a filled shape. Which modifier places a view on top?

Recap: Stroke, Fill & overlay

You learned to paint shapes with fill, outline them with stroke, and layer extras with overlay. You can now build real badges and cards!

Häufig gestellte Fragen

Ist die Lektion „Kontur, Füllung und overlay“ kostenlos?

Ja — der vollständige Text von „Kontur, Füllung und overlay“ 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 „Kontur, Füllung und overlay“?

Umranden und füllen Sie Formen für Badges und Karten. 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 4 von 4.

Wie lange dauert die Lektion „Kontur, Füllung und overlay“?

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. Der Typ Color und Asset-Farben
  2. Lineare, radiale und winkelförmige Farbverläufe
  3. Integrierte Formen
  4. Kontur, Füllung und overlay
← Zurück zu SwiftUI Academy