I am following an article to implement light and dark theme for one of my apps. The article can be found here. In this article, an interesting approach is used to edit all colors at once so there is no need to change all labels, backgrounds, ... separately. The new theme is set like this:
private func setNewTheme(_ newTheme: AppTheme) {
let window = UIApplication.shared.delegate!.window!!
UIView.transition(
with: window,
duration: 0.3,
options: [.transitionCrossDissolve],
animations: {
self.theme.value = newTheme
},
completion: nil
)
}
I suggest to read the article to understand the entire working of this mechanism. This works great and changes my backgrounds, colors of the UITabBar, colors of the UINavigationController etc. However, in some of my UIViewControllers, there is a UICollectionView which I would like to update as well. The colors remain the same, but I guess I need to reload the data in order for it to work?
My question is; how could I implement a functionality where my UICollectionViews would be reloaded when the other theme is set?
If the article I am mentioning is not best practice, please guide me towards the best way to implement this feature.