0

I am following this example.

@IBAction Func DarkButton(_sender:UISwitch) {
    if (sender.isOn) { 
        Theme.darkTheme() self.loadView()
    } else { 
        Theme.lightTheme()  self.loadView()
    }
}

I have lightTheme() and darkTheme() methods in a Theme struct. When I call self.loadview(), the theme changes the first time but afterward the switch value is not changing.

Connor Low
  • 5,900
  • 3
  • 31
  • 52
mk2019
  • 1
  • 1
  • Please see [mre]. – Connor Low May 21 '21 at 20:27
  • If `loadView` means the `UIViewController` method please consider [*You should never call this method directly*](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621454-loadview) – vadian May 24 '21 at 06:40
  • @vadian, how to achieve the background color change without using loadview() method, – mk2019 May 24 '21 at 10:21

0 Answers0