Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 prefersLargeTitles Weird Transition

So I'm having a weird issue with the new large titles in iOS 11. Instead of me trying to badly and confusingly explain the issue here is a 10-second screen recording of what is happening:

Screen recording of issue on YouTube

As you can see there is a weird black bar that appears when transitioning between a view controller that has

navigationItem.largeTitleDisplayMode = .never

And one that is set to .always

Thanks in advance!

like image 626
jackchmbrln Avatar asked Sep 14 '17 10:09

jackchmbrln


2 Answers

Before the transition set this:

self.navigationController?.view.backgroundColor = .white
like image 73
Pranav Kasetti Avatar answered Dec 07 '22 20:12

Pranav Kasetti


As Pranav said, the issue here is the background colour of the navigation controller's view, however, changing that from a child view controller is not the perfect way to do it.

Instead, a better way is to subclass UINavigationController and in the viewDidLoad() set the

override func viewDidLoad()
{
  super.viewDidLoad()
  view.backgroundColor = .white
}

Then, just use your custom subclass rather than the standard UINavigationController. This way, you only ever need this code in one place.

like image 36
Dave Verwer Avatar answered Dec 07 '22 19:12

Dave Verwer