When darkmode is enabled, UIViewControllers always use light mode. viewController.traitCollection.userInterfaceStyle is always Light but window.traitCollection.userInterfaceStyle is Dark.
UIUserInterfaceStyle is not set in plist. I tried all possible settings - adding UIUserInterfaceStyle to plist, setting overrideUserInterfaceStyle for UIWindow and for UIViewController. I logged userInterfaceStyle for different cases and results are
TestDarkModeViewController *testController = [[TestDarkModeViewController alloc] initWithNibName:@"TestDarkModeViewController" bundle: nil];
testController.traitCollection.userInterfaceStyle //result Light
but for
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:testController];
navController.traitCollection.userInterfaceStyle //result Dark
UIViewController *testController2 = [[UIViewController alloc]init];
testController2.traitCollection.userInterfaceStyle //result Dark
It seems it happens only when controller is programatically loaded from xib file. Any idea what can be wrong and how to solve this?