Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FirstViewController: UIViewController {
- @IBOutlet weak var lbl: UILabel!
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- if let switchStatus = (self.tabBarController as? TabBarController)?.switchStatus {
- lbl.text = switchStatus ? "Switch is On" : "Switch is off"
- }
- }
- }
- class SecondViewController: UIViewController {
- @IBOutlet weak var `switch`: UISwitch!
- @IBAction func switchAction(_ sender: UISwitch) {
- if let tabBar = self.tabBarController as? TabBarController {
- tabBar.switchStatus = sender.isOn
- }
- }
- }
- class TabBarController: UITabBarController {
- var switchStatus = true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement