0Pricing
SwiftUI Academy · Ders

Akış Düzeni Oluşturma

Satırları saran etiket tarzı bir düzen oluşturun.

Akış Düzeni Oluşturma, CoddyKit'te ücretsiz bir SwiftUI Academy dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, SwiftUI Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. SwiftUI Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

What Is a Flow?

A flow layout places items left to right and wraps to a new line when they run out of room, like word-wrapped text. 🏷️

Perfect for Tags

This wrapping behavior is exactly what you want for tag chips, hashtags, or filter pills of varying widths.

Start with Layout

Build it by conforming to the Layout protocol so you control wrapping yourself, since no stack wraps automatically.

struct FlowLayout: Layout {
    var spacing: CGFloat = 8
}

Measure Each Chip

In sizeThatFits, ask every subview for its size, then simulate placing them to find the total height needed.

let sizes = subviews.map {
    $0.sizeThatFits(.unspecified)
}

Track a Cursor

Keep an x and a y cursor. Move x rightward for each chip and reset when the next chip would overflow.

var x: CGFloat = 0
var y: CGFloat = 0

Detect Overflow

Before placing a chip, check if x plus its width exceeds the available width; if so, wrap to the next row.

if x + size.width > maxWidth {
    x = 0
    y += rowHeight + spacing
}

Advance the Row

After placing a chip, move x forward by its width plus spacing and grow rowHeight to the tallest chip seen.

x += size.width + spacing
rowHeight = max(rowHeight, size.height)

Place in the Second Pass

In placeSubviews, repeat the same wrapping math but call place at each computed point.

view.place(at: CGPoint(x: bounds.minX + x,
                       y: bounds.minY + y),
           proposal: .unspecified)

Return the Height

Your sizeThatFits should return the proposed width and the final y plus the last row height.

CGSize(width: maxWidth,
       height: y + rowHeight)

Drop It In

Now use it like any container: wrap your chips and the FlowLayout wraps them across as many lines as needed.

FlowLayout {
    ForEach(tags, id: \.self) { tag in
        TagChip(tag)
    }
}

Reusable Anywhere

Because it is a real Layout, your flow works with any views, adapts to width, and animates with the rest of SwiftUI. ✨

Quick Check

Recall what triggers a new row in a flow layout.

Recap

You built a wrapping FlowLayout with the Layout protocol, tracking a cursor to flow chips across rows automatically. 🎉

Sıkça Sorulan Sorular

“Akış Düzeni Oluşturma” dersi ücretsiz mi?

Evet — “Akış Düzeni Oluşturma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve SwiftUI Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. SwiftUI Academy kursu toplamda 4 dersten oluşur.

“Akış Düzeni Oluşturma” dersinde ne öğreneceğim?

Satırları saran etiket tarzı bir düzen oluşturun. SwiftUI Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

SwiftUI Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te SwiftUI Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Akış Düzeni Oluşturma” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu SwiftUI Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her SwiftUI Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. GeometryReader Temelleri
  2. Özel Hizalama Kılavuzları
  3. Layout Protokolü
  4. Akış Düzeni Oluşturma
← SwiftUI Academy Sayfasına Dön