Skip to content

Instantly share code, notes, and snippets.

Created January 10, 2018 02:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Broken iOS 11 NavigationBar
import UIKit
class ViewController: UIViewController {
let button = UIBarButtonItem(barButtonSystemItem: .add, target: nil, action: nil)
override func viewDidLoad() {
let searchBar = UISearchBar()
searchBar.searchBarStyle = .minimal
navigationItem.titleView = searchBar
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
if traitCollection.horizontalSizeClass == .regular {
navigationItem.leftBarButtonItem = button
} else {
navigationItem.leftBarButtonItem = nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment