I'm using Swift 5.1 and Xcode 11.1 and I've currently finished implementing Dark Mode design.
App has setting where user can set display theme(Light, Dark, System Default) and currently it's working fine if app restarts after user selects theme(I save this bool data in UserDefaults and set UIAppearance at app startup in AppDelegate file)
Here's my code
if #available(iOS 13.0, *) {
switch AppState.appThemeStyle {
case "dark":
window?.overrideUserInterfaceStyle = .dark
break
case "light":
window?.overrideUserInterfaceStyle = .light
break
default:
window?.overrideUserInterfaceStyle = .unspecified
}
}
But I can see that many apps change display themes immediately after user sets theme style.
I think It's not good idea to restart app for only changing theme and theme should change immediately after user sets theme style.
I tried to do that by setting base viewcontroller and set user interface style on ViewWillAppear but Navigation bar & Tab bar appearance doesn't change.
Could anyone please tell me how to handle this? Thanks.