Jinsujin / SwiftUI

SwiftUI를 공부해보고 활용하는 공간
0 stars 0 forks source link

Section #7

Closed Jinsujin closed 1 year ago

Jinsujin commented 1 year ago

문서 바로가기

Declaration

struct Section<Parent, Content, Footer>
init(
    content: () -> Content,
    header: () -> Parent,
    footer: () -> Footer
)
List {
    Section {
        HStack {
            Text("🧋")
            Text("Bubble tea")
        }
        HStack {
            Text("☕️")
            Text("Coffee")
        }
    } header: {
        Text("fruit")
    } footer: {
        Text("fruit footer")
    }
    Section { ... }
    Section { ... }
}
Jinsujin commented 1 year ago

예제

struct MySection: View {
    var body: some View {
        NavigationView {
            List {
                Section {
                    HStack {
                        Text("🧋")
                        Text("Bubble tea")
                    }
                    HStack {
                        Text("☕️")
                        Text("Coffee")
                    }
                } header: {
                    Text("fruit")
                } footer: {
                    Text("fruit footer")
                }

                Section {
                    HStack {
                        Text("🧁")
                        Text("Cupcake")
                    }
                    HStack {
                        Text("🍪")
                        Text("cookie")
                    }
                    HStack {
                        Text("🍦")
                        Text("ice cream")
                    }
                } header: {
                    Text("Dessert")
                } footer: {
                    Text("dessert footer")
                }
            }
            .navigationTitle("Caffee")
        }
    }
}