I created a segment picker for select gender in that segment picker I have to option one for Male and another for Female. Picker is working fine But set title on with picker it’s not showing. I set title Select Gender which is not showing as a title on the Picker.
struct ManagerChildrenView: View {
//MARK: Properties
@State var selectedGender = 0
let genders = ["Male", "Female"]
var body: some View {
Form{
Section{
Picker("Select Gender", selection: $selectedGender) {
ForEach(0..<genders.count) { index in
Text(self.genders[index]).tag(index).font(.title)
}
}.pickerStyle(SegmentedPickerStyle())
}
}
}
}
Screenshot:
Label is not used for SegmentedPickerStyle
. Instead you can use the following approach
HStack {
Text("Select Gender")
Picker("", selection: $selectedGender) {
ForEach(0..<genders.count) { index in
Text(self.genders[index]).tag(index).font(.title)
}
}.pickerStyle(SegmentedPickerStyle())
}
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