This framework is making use of embedded view controllers. What you need to do is add a property called VCA of type ViewControllerA to ViewControllerB's class:
class ViewControllerB: UIViewController {
var VCA: ViewControllerA!
}
Then, in ViewControllerA, you need to implement prepare(for segue:) so that, when ViewControllerB is initialized, you set its VCA property so that ViewControllerA is stored as ViewControllerB's VCA.
class ViewControllerA: UIViewController {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let VCB = segue.destination as? ViewControllerB {
VCB.VCA = self
}
}
}
Then, whenever clicking the theme button on ViewControllerB, you need to reference VCA and change its properties:
class ViewControllerB: UIViewController {
var VCA: ViewControllerA!
@IBAction func themeButtonPressed(_ sender: Any?) {
if UserDefaults.standard.bool(forKey: "DarkThemeOn") {
//Set the background color to light for both the menu VC and VCA
view.backgroundColor = .white
VCA.view.backgroundColor = .white
} else {
//Set the background color to dark for both the menu VC and VCA
view.backgroundColor = .black
VCA.view.backgroundColor = .black
}
//Toggle the theme
UserDefaults.standard.set(!UserDefaults.standard.bool(forKey: "DarkThemeOn"), forKey: "DarkThemeOn")
}
}