3
votes

I try add UISearchBarController to tableView, but when i set UINavigationBar.appearance().translucent = false then UISearchBar hide out of screen

in TableViewController

var resultSearchC: UISearchController = UISearchController()

override func viewDidLoad() {
    super.viewDidLoad()

    self.resultSearchC = ({
        let c = UISearchController(searchResultsController: nil)
        c.searchResultsUpdater = self

        c.searchBar.translucent = true

        c.searchBar.barTintColor =  .redColor()
        c.searchBar.sizeToFit()

        self.tableView.tableHeaderView = c.searchBar

        return c
    })()

    // self.edgesForExtendedLayout = .None

    self.tableView.reloadData()
}

AppDelegate:

let navBarAppearance = UINavigationBar.appearance()

    navBarAppearance.barStyle = .Black
    navBarAppearance.translucent = false
1

1 Answers

9
votes

You need to set extendedLayoutIncludesOpaqueBars to true in viewDidLoad().

extendedLayoutIncludesOpaqueBars = true;