<div class="meta" robots="noindex">

</div>

Class

# iOSSwitch

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2020r2. Please use `MobileSwitch</api/user_interface/mobile/mobileswitch>` as a replacement.

</div>

## Description

A Switch control is used to indicate an on/off, yes/no or true/false selection.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                               | Type                                     | Read-Only | Shared |
|----------------------------------------------------|------------------------------------------|-----------|--------|
| `AccessibilityHint<iosswitch.accessibilityhint>`   | `Text</api/deprecated/text>`             |           |        |
| `AccessibilityLabel<iosswitch.accessibilitylabel>` | `Text</api/deprecated/text>`             |           |        |
| `Enabled<iosswitch.enabled>`                       | `Boolean</api/data_types/boolean>`       |           |        |
| `Height<iosswitch.height>`                         | `Double</api/data_types/double>`         | ✓         |        |
| `Left<iosswitch.left>`                             | `Double</api/data_types/double>`         | ✓         |        |
| `Name<iosswitch.name>`                             | `Text</api/deprecated/text>`             | ✓         |        |
| `Parent<iosswitch.parent>`                         | `iOSControl</api/deprecated/ioscontrol>` | ✓         |        |
| `Top<iosswitch.top>`                               | `Double</api/data_types/double>`         | ✓         |        |
| `Value<iosswitch.value>`                           | `Boolean</api/data_types/boolean>`       |           |        |
| `Visible<iosswitch.visible>`                       | `Boolean</api/data_types/boolean>`       |           |        |
| `Width<iosswitch.width>`                           | `Double</api/data_types/double>`         | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                           | Parameters                                                         | Returns                                                   | Shared |
|------------------------------------------------|--------------------------------------------------------------------|-----------------------------------------------------------|--------|
| `AddConstraint<iosswitch.addconstraint>`       | constraint As `iOSLayoutConstraint</api/ios/ioslayoutconstraint>`  |                                                           |        |
| `AddControl<iosswitch.addcontrol>`             | child As `MobileControl</api/user_interface/mobile/mobilecontrol>` |                                                           |        |
| `Control<iosswitch.control>`                   | index As `Integer</api/data_types/integer>`                        | `MobileControl</api/user_interface/mobile/mobilecontrol>` |        |
| `ControlCount<iosswitch.controlcount>`         |                                                                    | `Integer</api/data_types/integer>`                        |        |
| `Handle<iosswitch.handle>`                     |                                                                    | `Ptr</api/data_types/additional_types/ptr>`               |        |
| `Invalidate<iosswitch.invalidate>`             |                                                                    |                                                           |        |
| `RemoveConstraint<iosswitch.removeconstraint>` | constraint As `iOSLayoutConstraint</api/ios/ioslayoutconstraint>`  |                                                           |        |
| `RemoveControl<iosswitch.removecontrol>`       | child As `MobileControl</api/user_interface/mobile/mobilecontrol>` |                                                           |        |
| `SetTintColor<iosswitch.settintcolor>`         | value As `Color</api/data_types/color>`                            |                                                           |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                   | Parameters | Returns |
|----------------------------------------|------------|---------|
| `Close<iosswitch.close>`               |            |         |
| `Open<iosswitch.open>`                 |            |         |
| `ValueChanged<iosswitch.valuechanged>` |            |         |

## Property descriptions

<div id="iosswitch.accessibilityhint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.AccessibilityHint

**AccessibilityHint** As `Text</api/deprecated/text>`

The accessibility hint is a longer description that is read aloud when VoiceOver is enabled.

``` xojo
Me.AccessibilityHint = "Click to calculate the value and display the next view."
```

<div id="iosswitch.accessibilitylabel">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.AccessibilityLabel

**AccessibilityLabel** As `Text</api/deprecated/text>`

The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.

``` xojo
Me.AccessibilityLabel = "Calculate the value."
```

<div id="iosswitch.enabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Enabled

**Enabled** As `Boolean</api/data_types/boolean>`

Enables or disables the switch.

Disable a Switch:

``` xojo
MySwitch.Enabled = False
```

<div id="iosswitch.height">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Height

**Height** As `Double</api/data_types/double>`

The height of the control.

This property is read-only.

<div id="iosswitch.left">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Left

**Left** As `Double</api/data_types/double>`

The left position of the control.

This property is read-only.

<div id="iosswitch.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Name

**Name** As `Text</api/deprecated/text>`

The name of the control. This can only be set in the Inspector. Use the name to refer to the control.

This property is read-only.

<div id="iosswitch.parent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Parent

**Parent** As `iOSControl</api/deprecated/ioscontrol>`

Indicates the control's parent object, if it has one. If there is no parent, this is Nil.

This property is read-only.

<div id="iosswitch.top">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Top

**Top** As `Double</api/data_types/double>`

The top position of the control.

This property is read-only.

<div id="iosswitch.value">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Value

**Value** As `Boolean</api/data_types/boolean>`

The value of the switch. On = True, Off = False.

If the Tax switch is on, then set the tax rate:

``` xojo
Var tax As Currency
If TaxSwitch.Value Then
  tax = 0.08
End If
```

<div id="iosswitch.visible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Visible

**Visible** As `Boolean</api/data_types/boolean>`

Indicates whether the control is visible.

Make a button invisible:

``` xojo
Button1.Visible = False
```

<div id="iosswitch.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Width

**Width** As `Double</api/data_types/double>`

The width of the control.

This property is read-only.

## Method descriptions

<div id="iosswitch.addconstraint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.AddConstraint

**AddConstraint**(constraint As `iOSLayoutConstraint</api/ios/ioslayoutconstraint>`)

Adds a constraint to the control. This constraint is used by child controls that have been added to this control.

<div id="iosswitch.addcontrol">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.AddControl

**AddControl**(child As `MobileControl</api/user_interface/mobile/mobilecontrol>`)

Adds a child control to the control.

<div id="iosswitch.control">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Control

**Control**(index As `Integer</api/data_types/integer>`) As `MobileControl</api/user_interface/mobile/mobilecontrol>`

Gets the child control at the specified index.

<div id="iosswitch.controlcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.ControlCount

**ControlCount** As `Integer</api/data_types/integer>`

The number of child controls in the control.

<div id="iosswitch.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

The handle is used to get a reference to the control for interfacing directly with the iOS API.

<div id="iosswitch.invalidate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Invalidate

**Invalidate**

Marks the control so that it will be redrawn during the next event loop.

Call Invalidate to force a Canvas to redraw itself:

``` xojo
Canvas1.Invalidate
```

<div id="iosswitch.removeconstraint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.RemoveConstraint

**RemoveConstraint**(constraint As `iOSLayoutConstraint</api/ios/ioslayoutconstraint>`)

Removes a constraint from the control.

<div id="iosswitch.removecontrol">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.RemoveControl

**RemoveControl**(child As `MobileControl</api/user_interface/mobile/mobilecontrol>`)

Removes the control from the control.

<div id="iosswitch.settintcolor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.SetTintColor

**SetTintColor**(value As `Color</api/data_types/color>`)

Changes a control's tint color. This varies by control and for some controls may not do anything. For example, with an `MobileTextField</api/user_interface/mobile/mobiletextfield>` this changes the cursor color.

## Event descriptions

<div id="iosswitch.close">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Close

**Close**

Called when the control is removed from its container, such as a view.

<div id="iosswitch.open">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.Open

**Open**

Called after the control is created. This is where you typically put initialization code.

Set label text in Open event:

``` xojo
Me.Text = "Hello"
```

<div id="iosswitch.valuechanged">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSSwitch.ValueChanged

**ValueChanged**

Called when the value property is changed either by code or by the user.

Disable an iOSTextField when the switch is off and enable it when on:

``` xojo
If Me.Value Then
  MyTextField.Enabled = True
Else
  MyTextField.Enabled = False
End If
```

## Compatibility

iOS projects on the iOS operating system.
