-1

I recently updated to Xcode 11.1 and the update came along with a lot of random changes to the story board. I have fixed all but one.

The navigation bar is completely transparent when the large title is used.

As soon as I scroll down on the other hand, the navigation bar uses the smaller title as intended and is visible.

When I take a look at the storyboard, the navigation controller's navigation bar is not visible.

I have played around with the attributes inspector to no avail. I don't believe that this issue is caused by the search bar but this is how I implimented it:

searchController declaration:

let searchController = UISearchController(searchResultsController: nil)

In viewDidLoad():

searchController.searchBar.delegate = self
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search \(clubs.count) clubs"
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

-1

iOS 13 uses a new UINavigationBarAppearance() object to change the attributes of the nav bar.

When the nav bar is at the top, it uses the scrollEdgeAppearance.

By changing the scollEdgeAppearance of the nav bar, it is possible to change the background color.

if #available(iOS 13.0, *) {
    let appearance = UINavigationBarAppearance()
    appearance.backgroundColor = .white
    navigationController?.navigationBar.scrollEdgeAppearance = appearance
} else {
    print("iOS version too low!")
}
  • This is all true, but it's not new. It's been discussed in many Stack Overflow questions and answers already. So please let's not waste bandwidth on it once again. We want Stack Overflow to be definitive encylopedia of programming knowledge, not a personal blog of discovery. – matt Oct 25 '19 at 02:30