Saturday, June 13, 2026
HomeiOS Developmentswift - SwiftUI Picker Label with PickerStyle .menu in iOS HowTo

swift – SwiftUI Picker Label with PickerStyle .menu in iOS HowTo

[ad_1]

So as to add a Label View out of the field with out customized View one has to make use of Picker in Menu View embedded.
Now one can use modifier on the Menu Label Views and even use logic for the chosen textual content.

Menu {
    Picker(choice: $gender,
        label: EmptyView(),
        content material: {
            Textual content(Gender.male.rawValue).tag(Gender.male)
            Textual content(Gender.feminine.rawValue).tag(Gender.feminine)
            Textual content(Gender.nobinary.rawValue).tag(Gender.nobinary)
        }).pickerStyle(.automated)
           .accentColor(.white)
    } label: {
        Textual content(gender == .unselected ? "Choose your gender" : gender.rawValue)
            .font(.title3)
            .body(maxWidth: .infinity)
            .body(top: 55)
            .background(.white)
            .cornerRadius(10)
            .accentColor(.pink)
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments