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:
Asked
Active
Viewed 931 times
2

George
- 25,988
- 10
- 79
- 133

Just A Question
- 423
- 6
- 21
-
For the simplest solution Try toolbar and principal vs navigation title – lorem ipsum Aug 30 '21 at 12:27
1 Answers
0
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"))
}
}

Alhomaidhi
- 517
- 4
- 12
-
-
-
I want to achieve this translucent look so that you can see the content through the navigation bar – Just A Question Sep 01 '21 at 10:24