Tengo un Picker de Menu de estilo y necesito cambiar su tamaño de texto (el texto azul), probé el .font(.largeTitle) pero no funcionó.
enum Privacy: String, Identifiable, CaseIterable { case open = "Open" case closed = "Closed" var id: String { self.rawValue } } struct ContentView: View { @State var selection = Privacy.open var body: some View { Picker("Privacy", selection: $selection) { ForEach(Privacy.allCases) { value in Text(value.rawValue) .tag(value) .font(.largeTitle) } } .font(.largeTitle) .pickerStyle(.menu) } }Elimine el estilo .menu y envuélvalo en Menu en su lugar, con una etiqueta personalizada:
Menu { Picker(selection: $selection) { ForEach(Privacy.allCases) { value in Text(value.rawValue) .tag(value) .font(.largeTitle) } } label: {} } label: { Text("Privacy") .font(.largeTitle) }Si alguien necesita mostrar el valor seleccionado como etiqueta (en lugar de texto estático) en este escenario, se puede usar la siguiente variante
Probado con Xcode 13.2 / iOS 15.2
Menu { Picker(selection: $selection) { ForEach(Privacy.allCases) { value in Text(value.rawValue) .tag(value) } } label: {} } label: { Text(selection.rawValue) .font(.largeTitle) }.id(selection)Descubrí que el truco Menu { Picker() {} } hizo cosas rotas en Mac (anida el menú adecuado dentro de un menú de un solo elemento). Pero este ligero mod hasta ahora funciona limpiamente en iPhone, iPad y Mac:
Menu { ForEach(RowLabelType.allCases, id: \.self) { type in Button { todayTabRowLabels = type } label: { Text(type.displayString) } } } label: { Text(todayTabRowLabels.displayString) }