Friday, November 6, 2026
HomeiOS Developmentios - SwiftUI - Part fashion distinction when embedding Checklist inside a...

ios – SwiftUI – Part fashion distinction when embedding Checklist inside a VStack

[ad_1]

It appears that there’s a distinction in exhibiting a Checklist Part header while you embed the Checklist in a VStack. Does anyone know why this occurs?

struct ContentView: View {
@State var toggle: Bool = false

let gadgets: [String] = ["Apple", "Pear", "Banana"]

var physique: some View {
    NavigationView {
        if toggle {
            VStack {
                checklist
            }
        } else {
            checklist
        }
    }
    
}

var checklist: some View {
    Checklist {
        Part {
            ForEach(gadgets, id: .self) { merchandise in
                Textual content(merchandise)
            }
        } header: {
            Textual content("Fruit")
        }
    }
    .navigationTitle(toggle ? "VStack" : "No VStack")
    .navigationBarTitleDisplayMode(.inline)
    .toolbar {
        ToolbarItem(placement: .navigationBarTrailing) {
            Button {
                toggle.toggle()
            } label: {
                Textual content("Toggle")
            }
            
        }
    }
}

}

enter image description here

enter image description here

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments