swift switch button code example
Example 1: switches xcode
@IBAction func switchO(_ sender: Any) {
if ((sender as AnyObject).isOn == true) {
labelO.text = "Yes I Do" } else {
labelO.text = "No I Do Not"
}
}
Example 2: switch button swift 5
@IBAction func switch(_ sender: Any) {
if ((sender as AnyObject).isOn == true) {
//Yes
} else {
//No
}
}