'Removing the space above the searchable search bar in navigation view in SwiftUI
I am testing out the SwiftUI's feature .searchable(). But seems that the search bar would always has a space above it. Since the searchable is embedded in the naviagation bar, I understand the space as where the Navigation bar items go. But is there a way to remove that space and make the searchbar looking like that in Instagram? I have tried changing the navbar style to inline,as the code below, but there is still some space above it. Is there any logic behind the search bar's position?
NavigationView{
SearchView(searchText: $searchText)
.navigationBarTitleDisplayMode(.inline)
}
.searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always), suggestions: {
ForEach(searchResults, id: \.self){result in
Text(result).searchCompletion(result)
}
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
