How to link a boolean value to the on/off state of a UISwitch?

前端 未结 7 1393
深忆病人
深忆病人 2020-12-24 12:11

I have a UISwitch that I want to control a boolean value in a function I wrote. I looked in the UISwitch Type Reference and it listed the property

相关标签:
7条回答
  • 2020-12-24 13:05

    No need for extra boolean.
    use this :

    if mySwitch.isOn {
      // do something
    } else {
      // do something else
    }
    

    this is an always up to date boolean for switch state, so NO NEED to create your own variable.

    0 讨论(0)
提交回复
热议问题