I have made two different theme for my application, users can select them from the setting, I defined colors in the module and in the control, in a function, I defined color for every element in the screen.
The problem is, I have to add this function to viewdidload
, but when I go to setting and change the them, and come back to the page, the them will not changed, and I have to close the app in the simulator and open it again to see the changes, apparently viewdidload
only execute once when the app will open, but it doesn't execute when the change the page. Is there anyway that I can use like viewdidload
but it will execute every time that I enter the page? and It is not needed to close the app completely and open it again to see the changes.
Thanks for your help
You can use viewWillAppear()
instead of viewdidload
and it will be called every time that ViewController has appeared
override func viewWillAppear(_ animated:Bool)
super.viewWillAppear(animated)
//Your changes
}