Mobile Switch

From Xojo Documentation

A Switch has an on/off position and is used to choose a preference. When the Switch is on, it appears with a green background.

iOS Switch Library Icon

Below are commonly used events and properties. Refer to MobileSwitch in the Language Reference for the complete list.



Called when the value for the Switch is changed, either by the user clicking on it or by code changing its Value property.



A boolean that indicates if the switch is enabled and can be tapped or disabled and cannot be changed.


A boolean that indicates the state of the Switch. When True, the Switch is on and displays with a green background. When False, the Switch is off.


iOS Switch shown ON and OFF

To turn a switch on, set its value property:

MySwitch.Value = True

This code in the ValueChanged event handler enables or disables a Text Field depending on whether a Switch is on or off:

If Me.Value Then
MyTextField.Enabled = True
MyTextField.Enabled = False
End If

Example Projects

  • Examples/iOS/Controls/SwitchExample

See Also

MobileSwitch class; UserGuide:iOS User Interface Controls topic