iOS.Blog.SwiftUI_Search_Bar_in_Navigation_Bar
iOS.Blog.SwiftUI_Search_Bar_in_Navigation_Bar copied to clipboard
How to show searchbar on load
Hi, thanks for making this clean example of adding a searchbar. I've been looking but unable to find a way to show the SearchBar by default without having to pull down on the view. Is there a simple way to change this? Thanks
I'm interested too
is there any update on a solution?
Please take a look at these other branches below as well, as in some cases there is a search bar visible when the view opens.
Prototype/UI/UIKit_Navigation_Stack
Prototype/UI/UIKit_Navigation
Prototype/UI/SwiftUI_Navigation
@skunkworker @aksonov @FUNKYJASPER2 Hi, guys👋. If the question is still relevant, for (iOS 13.0, *) and SwiftUI add the following:
ViewControllerResolver { viewController in
viewController.navigationItem.searchController = self.searchBar.searchController
viewController.navigationController?.navigationBar.sizeToFit() // This line rocks
}
Original StackOverflow answer: https://stackoverflow.com/a/67721006