import SwiftUI public struct CaseIterablePicker: View where Content: CaseIterable, Content: CustomStringConvertible, Content: Hashable, Content: Identifiable, Content.AllCases: RandomAccessCollection, Label: View { let label: () -> Label @Binding var selection: Content public init( selection: Binding, @ViewBuilder label: @escaping () -> Label ) { self.label = label self._selection = selection } public var body: some View { Picker(selection: $selection, label: label()) { ForEach(Content.allCases) { Text($0.description) .tag($0) } } } } extension CaseIterablePicker where Label == Text { public init(_ title: S, selection: Binding) { self.init(selection: selection) { Text(title) } } }