问题
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!
回答1:
Before the transition set this:
self.navigationController?.view.backgroundColor = .white
回答2:
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.
来源:https://stackoverflow.com/questions/46217241/ios-11-preferslargetitles-weird-transition