How can I have an image and text in one section of a SwiftUI SegmentedPickerStyle picker

439 Views Asked by At

I have a picker with segmentedPickerStyle and I want each section to have text and a small image. The problem is with the approach below I get 4 segments instead of 2. One for each text and one for each image. Is there any way to have the text and image together in one segment using only swiftui. I know I can create an image with text in the image but was wondering if there is a pure swiftUI way to do this using Text and Image

Picker(selection: $pickerSelection, label: Text("choose")) {
    HStack {
        Text("One")
        Image("firstImage")
    }
    .tag(0)
    HStack {
        Text("Two")
        Image("secondImage")
    }
    .tag(1)
}
.pickerStyle(SegmentedPickerStyle())
0

There are 0 best solutions below