Large Title Navigation Bar Overlaps when switching tabs

Using a navigation controller in a tab bar controller the large title glitches when switching tabs.

SceneDelegate.swift


if let windowScene = scene as? UIWindowScene {
  let window = UIWindow(windowScene: windowScene)

  let tabBarController = UITabBarController()
  tabBarController.viewControllers = [UINavigationController(rootViewController: ViewController()), UIViewController()]

  window.rootViewController = tabBarController
  self.window = window
  window.makeKeyAndVisible()
  }


ViewController.swift


self.view.backgroundColor = .systemBackground

  self.title = "Main"
  self.navigationController?.navigationBar.prefersLargeTitles = true
  self.navigationItem.largeTitleDisplayMode = .always

  scrollView = UIScrollView(frame: self.view.bounds)
  self.view.addSubview(scrollView)

  let contentView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 1400))
  contentView.backgroundColor = .gray
  self.scrollView.addSubview(contentView)

  scrollView.contentSize.height = 1700



Steps to reproduce:

  • Scroll down until the large title collapses into the small title
  • Switch to the second tab
  • Switch back to the first tab
  • Result: The scroll view is still scrolled down but the large title now overlaps the content. When scrolling a little bit, it snaps back to the small title.

This does not happen when it’s a table or collection view instead of the scroll view.

This started happening in iOS 13. Did I miss some change in the behavior or is this a bug? Does someone know a workaround?

I'm having the same issue, however I'm using SwiftUI. Did you find a solution?
Large Title Navigation Bar Overlaps when switching tabs
 
 
Q