After 2 days try, I'm posting this question here. I need to achieve this [![enter image description here](https://i.stack.imgur.com/MZpm7.png)](https://i.stack.imgur.com/MZpm7.png) 

in swift 4. I've tried below:-

```
let switchOnOff = UISwitch(frame:CGRect(x: 150, y: 150, width: 200, height: 0))

    switchOnOff.addTarget(self, action: #selector(self.switchStateDidChange), for: .valueChanged)
    switchOnOff.setOn(true, animated: false)
    self.view.addSubview(switchOnOff) 

 @objc func switchStateDidChange(sender:UISwitch){
    if (sender.isOn == true){
        sender.setOn(true, animated: false)
        //sender.onImage = UIImage(named: "edit.png")
    }
    else{

        sender.setOn(false, animated: false)
        //sender.offImage = UIImage(named: "offSwitch.png")

    }
}

```

sender.onImage , sender.offImage not working in this ios 10+ version.
Then I tried to use `sender.tag` , `sender.text`

These are also not working. Not getting any proper help in googling.
So please help me if You already solved this matter.

Thanks Guys.