I have an iOS app that had its own theming system (dark/light UI styling) before iOS 13 introduced it natively. This is partly achieved via the UIAppearance
methods on various UI elements, like bar button items, segmented controls, and such.
To integrate my themes with the iOS light and dark styles, I'd like to automatically switch my themes when the system changes between dark and light mode. I can accomplish this mostly by implementing traitCollectionDidChange
on various view and view controller classes and calling my own theme update methods if the UI style has changed. But I also need to trigger an update of the UIAppearance setup, and I'd like to do this only once per system UI style change.
My question: how do I know centrally, in one place, when the iOS system light/dark mode has changed? I'm hoping for the color appearance equivalent of UIContentSizeCategoryDidChangeNotification
. This would also mean less repetitive code implementing traitCollectionDidChange
everywhere.
I could trigger it on traitCollectionDidChange
in my root view controller, but once I implement multi-scene support for iPadOS, I no longer really have one "root" view controller.