UISearchController - search bar should be visible always
<p><strong>Aim:</strong> To have a search bar that is always visible.</p>

<ol>
<li>View controller is embedded in a navigation controller</li>
<li>No table view exists</li>
<li>When user taps on search bar, search bar needs to animate from its current position to the top of the navigation bar (move <strong>upwards</strong>) like in the <strong>iOS contacts app</strong>.</li>
<li>Use <code>UISearchController</code></li>
</ol>

<p><strong>What I have done:</strong></p>

<ol>
<li>I have added the search bar to the view controller's view</li>
<li>I am manually presenting the search view controller (code below)</li>
</ol>

<p><strong>Problem:</strong></p>

<ul>
<li>I am unable to control the animation, presently the search bar moves <strong>downwards</strong> from top of the screen to the place of the navigation bar.</li>
</ul>

<p><strong>Expected behavior:</strong></p>

<ul>
<li>To be able to animate the search bar by moving it <strong>upwards</strong> from the current position to the navigation bar</li>
</ul>

<p><strong>Question</strong></p>

<ol>
<li>Is my approach correct ?</li>
<li>How can i animate and move the search bar upwards from the current position ?</li>
</ol>

<p><strong>Code:</strong></p>

<pre><code>    func setupSearchController() {
        searchController.searchResultsUpdater = self
        self.definesPresentationContext = false
        searchController.delegate = self
        searchController.hidesNavigationBarDuringPresentation = true

        let searchBar = searchController.searchBar

        view.addSubview(searchBar)

        searchBar.translatesAutoresizingMaskIntoConstraints = false

        searchBar.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor).active = true
        searchBar.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor).active = true
        searchBar.topAnchor.constraintEqualToAnchor(topLayoutGuide.bottomAnchor).active = true

    }

    func presentSearchController(searchController: UISearchController) {
        let searchBar = searchController.searchBar

        searchBar.removeFromSuperview()

        let baseView = searchController.view

        baseView.addSubview(searchBar)

        searchBar.leadingAnchor.constraintEqualToAnchor(baseView.leadingAnchor).active = true
        searchBar.trailingAnchor.constraintEqualToAnchor(baseView.trailingAnchor).active = true
        searchBar.topAnchor.constraintEqualToAnchor(searchController.topLayoutGuide.bottomAnchor).active = true

        self.presentViewController(searchController, animated: true) {

        }
    }
</code></pre>