Hi there, I'm Marcos!

Back

Segmented picker

If you want to have a segmented picker in your application like the one below you need to set the picker style of your Picker view to segmented:

Image showing a segmented picker with 4 icons representing the different seasons

struct SeasonSelectorView: View {
    @State var season: Season = .summer

    var body: some View {
        Picker("Select the period", selection: $season) {
            Text(Season.spring.rawValue).tag(Season.spring)
            Text(Season.summer.rawValue).tag(Season.summer)
            Text(Season.autumn.rawValue).tag(Season.autumn)
            Text(Season.winter.rawValue).tag(Season.winter)
        }.pickerStyle(.segmented)
    }
}