swift 5 UIswitch value change was not working when using loadview method

84 Views Asked by At

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.

0

There are 0 best solutions below