I may be mistaking what you mean by doesn't work, so assume showing a search bar would be your primitive purpose here.
Please try something like this:
struct ContentView: View {
var body: some View {
NavigationView {
TabView{
VStack{
List{
Text("aaa")
Text("bbb")
Text("ccc")
}
}
.tabItem({
Text("tab1")
})
VStack{
Text("tab2")
}
.tabItem({
Text("tab2")
})
}
.searchable(text: .constant("")) //<- `searchable` added to `TabView`
}
}
}
In your code, TabView is the only child view of NavigationView. And searchable modifier needs to be placed on any of the direct child view of NavigationView, or on the NavigationView itself.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: