After updating to iOS 15 and Xcode 13, my picker in my app is no longer showing a custom label. Running the app on an iOS 14 device, the pickers render fine.
This is the code snippet that is currently implemented and the screenshot is what it currently looks like in the simulator on iOS 15.
@State var selectedNumber: Int = 0
var body: some View {
Picker(selection: $selectedNumber, label: customLabel) {
ForEach(0..<10) {
Text("\($0)")
}
}
}
var customLabel: some View {
HStack {
Image(systemName: "paperplane")
Text(String(selectedNumber))
Spacer()
Text("⌵")
.offset(y: -4)
}
.foregroundColor(.white)
.font(.title)
.padding()
.frame(height: 32)
.background(Color.blue)
.cornerRadius(16)
}

The answer @Adam provided worked. Below is what I did to fix it in case someone else stumbles on problem.
@State var selectedNumber: Int = 0
var body: some View {
Menu {
Picker(selection: $selectedNumber, label: EmptyView()) {
ForEach(0..<10) {
Text("\($0)")
}
}
} label: {
customLabel
}
}
var customLabel: some View {
HStack {
Image(systemName: "paperplane")
Text(String(selectedNumber))
Spacer()
Text("⌵")
.offset(y: -4)
}
.foregroundColor(.white)
.font(.title)
.padding()
.frame(height: 32)
.background(Color.blue)
.cornerRadius(16)
}
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