I have a Picker
of style Menu
and I need to change its text size (the blue text), I tried the .font(.largeTitle)
modifier but it didn't work.
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)
}
}
Remove the .menu
style and just wrap it in Menu
instead, with a custom label:
Menu {
Picker(selection: $selection) {
ForEach(Privacy.allCases) { value in
Text(value.rawValue)
.tag(value)
.font(.largeTitle)
}
} label: {}
} label: {
Text("Privacy")
.font(.largeTitle)
}
If someone needs to show selected value as label (instead of static text) in this scenario, the following variant can be used
Tested with 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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With