1

I'm trying to create a SwiftUI Menu containing two Picker to control content and sort. However, I cannot replicate menu appearance shown in my reference screenshot.

No matter which approach I try, I get unwanted extra dividers or incorrect text styling:

  1. Using Section with titles: Creates extra dividers before and after each section, separating the title from the picker options

  2. Using Text().disabled(true) as headers: Same issue - extra dividers appear

  3. Adding disabled text as first picker item: The text still renders as an active/selectable item instead of a disabled header

I want to achieve the clean appearance shown in the reference screenshot, where section headers appear inside a picker.

Current Code:

swift

Menu {
    Text("Content")
        .foregroundStyle(.secondary)
        .disabled(true)
    contentPicker
    
    Divider()
    
    Text("Sort direction")
        .foregroundStyle(.secondary)
        .disabled(true)
    sortDirectionPicker
} label: {
    Image(systemName: allFiltersEnabled ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill")
}

Reference screenshot

My menu

What is the correct way to structure multiple Pickers within a Menu to match this appearance without extra dividers around section headers?

0

1 Answer 1

0

To match the reference screenshot, you need to use the Picker's label (title):

Picker("Sort direction", selection: $sortDirection) {
    Text("Oldest first").tag("asc")
    Text("Newest first").tag("desc")
}
.pickerStyle(.inline)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.