HomeiOS Developmentios - SwiftUI cross Views from mum or dad to baby

ios – SwiftUI cross Views from mum or dad to baby


I need to have a customized SwiftUI View which renders & kinds Views handed to it from its mum or dad.

I attempted with this code:

struct CustomView<Content material: View>: View {
    let views: [Content]
    
    init(_ views: [Content]) {
        self.views = views
    }
    
    public var physique: some View {
        VStack {
            ForEach(views.indices, id: .self) { index in
                let view = views[index]
                view
                    .padding(.main, 15)
            }
        }
    }
}
struct OuterView: View {
    @State var choice: String
    
    var physique: some View {
        CustomView([
            HStack(content: {
                Text("details")
                Spacer()
                Image(systemName: "chevron.right")
            }),
            HStack(content: {
                Text("attend")
                Spacer()
                Picker(selection: $selection) {
                    Text("full")
                } label: {
                    EmptyView()
                }
            })
        ])
    }
    
}

I get the next error: “Can not convert worth of sort ‘Picker<EmptyView, String, Textual content>’ to anticipated argument sort ‘Picture'”

It appears that evidently the code expects each View to take the identical type.

How can I modify this code so that every view handed via could be distinctive?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments