UISearchBar is below status bar after rotation (back to portrait mode)

Reproduce (bug only with iPhone devices <= 8, works ok with iPhone X* devices):


1. Open search bar (by clicking search item on top bar) in portrait mode


@IBAction func onSearchBarItemClicked(_ sender: UIBarButtonItem) {
    present(searchController, animated: true, completion: nil)
}


https://i.stack.imgur.com/nE7eT.png


2. Rotate device to landscape position


https://i.stack.imgur.com/agf8V.png


3. Rotate back to portrait position


https://i.stack.imgur.com/SZ1WD.png


Now it's below status bar and it overlaps the content at bottom


How can I fix it?


UISearchController:


    searchController = UISearchController(searchResultsController: nil)
    searchController.hidesNavigationBarDuringPresentation = false
    searchController.dimsBackgroundDuringPresentation = false
    searchController.searchBar.keyboardType = UIKeyboardType.asciiCapable
    searchController.searchBar.delegate = self

Replies

Sample Project: https://github.com/anonym24/SearchBarBelowStatusBar/