Monday, August 17, 2026
HomeiOS Developmentios - Change DisclosureGroup indicator picture in SwiftUI

ios – Change DisclosureGroup indicator picture in SwiftUI

[ad_1]

I’m attempting to alter the indicator picture of the DisclosureGroup in SwiftUI. Ideally I might desire a customized picture. I’ve tried to attain that utilizing my very own ButtonStyle

struct TestButtonStyle: ButtonStyle {
    func makeBody(configuration: Configuration) -> some View {
        configuration.label
        HStack {
            Spacer()
            Picture(systemName: "pencil")
        }
    }
}


struct DropDownMenu2 : View {
    
    var gadgets: [String]
    @State var broaden = false
    @State var selectedItem: String
    
    init(gadgets: [String]) {
        self.gadgets = gadgets
        self.selectedItem = gadgets[0]
    }
    
    var physique: some View {
        VStack(alignment: .main) {
            DisclosureGroup("(selectedItem)", isExpanded: $broaden) {
                VStack {
                    ForEach(gadgets, id: .self) { merchandise in
                        Textual content("(merchandise)")
                            .onTapGesture {
                                self.selectedItem = merchandise
                                withAnimation {
                                    self.broaden.toggle()
                                }
                            }
                    }
                }
            }
            .padding(.all)
            .buttonStyle(TestButtonStyle()).accentColor(.grey)
            .background(Shade.grey)
            .cornerRadius(8)
        }
        Spacer()
    }
    
}

Outcome to this point:
enter image description here

I would love that pencil icon parallel to Filter 1 textual content as is the case with commonplace DisclosureGroup. How can I obtain that?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments