Reputation: 530
What Im trying to achieve is to have a segmented picker inside the navigation bar, but below the title of the navigation bar while still having the collapse animation. For example instead of the search, I need a segmented picker:
Upvotes: 2
Views: 1548
Reputation: 666
This does not look like that but it could work.
NavigationView {
List {
Text("SwiftUI")
}
.navigationTitle("Title")
.toolbar {
ToolbarItem(placement: .primaryAction) {
VStack {
Picker("", selection: $selectedOption) {
ForEach(options, id:\.hashValue) {option in
Text(option)
}
}
}
}
}
}
If it doesn't need to collapse you can do this.
NavigationView {
VStack {
Picker("", selection: $selectedOption) {
ForEach(options, id:\.hashValue) {option in
Text(option)
}
}
.pickerStyle(SegmentedPickerStyle())
.padding(.horizontal)
List {
ForEach(options, id:\.self) {
searchText in Text(searchText)
}
}
.navigationBarTitle(Text("Select"))
}
}
Upvotes: 0