minimal searchbar style in navigation item?

I've been banging my head on this for a while, and can't for the life of me figure out how to set the searchBarStyle of a UISearchController's searchBar to .minimal, when it's in a navigation item.


let controller = UISearchController(searchResultsController: nil)
controller.hidesNavigationBarDuringPresentation = true
controller.obscuresBackgroundDuringPresentation = false

controller.searchBar.searchBarStyle = .minimal

controller.searchResultsUpdater = self
controller.searchBar.delegate = self

self.searchController = controller
self.navigationItem.searchController = controller


Am I doing something wrong? Or is this just not supported publicly? As far as I can tell, the default Notes app does something very similar to this, so I'd expect it to be supported, but I simply can't figure it out.

Replies

I'm still stuck on this. I have no ideas.

Could you describe what you expect and what you get ?


Does it work if you set to .prominent ? or .default ?

I mention the default Notes app because I'm trying to do something similar. I have a table view of searchable notes. I want everything to be transparent because I have a textured paper background. When you pull the view down, it reveals the search bar.


In the stock Notes app, the search bar "has no background and the search bar is translucent", exactly like described in the .minimal style.


But when I try to do the same in my app, the search bar has a white background – which stands out against the paper texture. If I view it in the "Debug View Heirarchy" I can see that the search bar does indeed have a white background, even though it's not supposed to.


Setting it to .prominent or .default doesn't change anything, like it's completely ignored. I can verify it's still set in updateSearchResults(for:) though.