I have this NavigationController
hat has Large Titles enabled for its NavigationBar
. The root ViewController
has a SearchController
, and hidesSearchBarWhenScrolling is set to True in the ViewController
's NavigationItem
as I don't want the SearchBar
to be always visible. The ViewController
has a TableView
and when you tap on one of its items a new instance of the same ViewController
will be pushed onto the Navigation stack using a storyboard segue. However, when looking at the transition between the current and the new ViewController
one can observe that the animation doesn't look right: As soon as the new ViewController
is moved in the SearchBar
becomes empty, just showing its background. When the new ViewController
is finally fully visible, the SearchBar
will go away without any animation.
This is how I add the SearchController
(nothing fancy here):
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
}
}
And so it looks like when navigating from "One" to "Two":
UISearchController / UINavigationBar shows broken animation when used within UINavigationController
Is there a way to make this look nicer? Of course, in the new ViewController
the SearchBar
should not be initially visible, so it has to go away somehow. But I would think that the SearchBar
on the old ViewController
perhaps should be faded out somehow instead of staying there and then suddenly hiding when the transition to the new ViewController
is finished. Hopefully I'm just doing something wrong here...
Thanks and Merry Xmas to all of you,
Peter