I am getting multiple white lines when clicking in the SearchBar.
It is happening when using both a TabBarController and a colored bar NavigationController, but
I setup the navigation color in the AppDelegate using this line of code:
UINavigationBar.appearance().barTintColor = UIColor(rgb: 0x0277BD)
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
And I setup the UISearchController in my SearchViewController using:
let searchController = UISearchController(searchResultsController: nil)
override func viewDidLoad() {
super.viewDidLoad()
// Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search Events"
searchController.searchBar.tintColor = .white
navigationItem.searchController = searchController
definesPresentationContext = true
}
Any idea of what is happening?
Not sure if this is a satisfying answer but it looks like an iOS bug, that might have something to do with the translucency effect that's added by default to the top bar. The top bar consists of two parts (navigation & search) and it seems like the white line appears on the bottom edge of the navigation part during the slide-up animation. If you add navigationController?.navigationBar.isTranslucent = false
to your viewDidLoad()
the problem goes away.
Why does the white line appear only when you embed the UINavigationController
in the UITabBarController
? No idea :(
The isTranslucent = false
thing is a workaround at best, but maybe it's enough.