I had the strangest issue today. When testing my current app on iOS 10, the navigation bar would sit below the status bar. In other words, the navigation bar would be 44 pixels high, instead of 64 pixels. On iOS 11, this issue wasn't present.
This happened because our app does not use storyboards, and we used the following AppDelegate.swift:
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let mainViewController = ViewController() let navigationController = UINavigationController(rootViewController: mainViewController) self.window?.rootViewController = navigationController self.window?.makeKeyAndVisible() return true }
}
The problem is, that the window property is initialized too early. Moving it to didFinishLaunching fixes the problem:
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { self.window = UIWindow(frame: UIScreen.main.bounds) let mainViewController = ViewController() let navigationController = UINavigationController(rootViewController: mainViewController) self.window?.rootViewController = navigationController self.window?.makeKeyAndVisible() return true }
}