Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. class FirstViewController: UIViewController {
  2.  
  3. @IBOutlet weak var lbl: UILabel!
  4. override func viewWillAppear(_ animated: Bool) {
  5. super.viewWillAppear(animated)
  6. if let switchStatus = (self.tabBarController as? TabBarController)?.switchStatus {
  7. lbl.text = switchStatus ? "Switch is On" : "Switch is off"
  8. }
  9. }
  10. }
  11.  
  12. class SecondViewController: UIViewController {
  13.  
  14. @IBOutlet weak var `switch`: UISwitch!
  15.  
  16. @IBAction func switchAction(_ sender: UISwitch) {
  17. if let tabBar = self.tabBarController as? TabBarController {
  18. tabBar.switchStatus = sender.isOn
  19. }
  20. }
  21. }
  22.  
  23. class TabBarController: UITabBarController {
  24. var switchStatus = true
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement