Skip to content
Mohammad Azmal Hossain edited this page Mar 5, 2017 · 1 revision

let switchDemo=UISwitch()

    switchDemo.isOn = true
    switchDemo.setOn(true, animated: false);
    switchDemo.addTarget(self, action: #selector(switchValueDidChange), for: .valueChanged)
    self.view.addSubview(switchDemo);
    
 
 // }
  // this func put outside of sliderDemo scope
    if (sender.isOn == true){
      print("on")
    }
    else{
      print("off")
    }
  }
Clone this wiki locally