How to detect app is dark mode or light in ios 13, also set simulator in dark mode.


if self.traitCollection.userInterfaceStyle == .dark {
print("App is Dark Mode")
} else {
print("App is Light Mode")
}

When you go to setting and update dark mode or light mode then come to app after call this method.


override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
print("Trait collection has already changed")
}

override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
print("Trait collection will be change")
}

How to detect in objective C


if ([self.traitCollection userInterfaceStyle] == UIUserInterfaceStyleDark)
{
NSLog(@"Dark Mode");
}else {
NSLog(@"Light Mode");
}

Set Simulator in Dark Mode

GO to setting
GO to Developer
Switch to Dark Appreance