<!--
{
  "availability" : [
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WatchKit",
  "identifier" : "/documentation/WatchKit/WKInterfaceSwitch",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "WatchKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKInterfaceSwitch"
  },
  "title" : "WKInterfaceSwitch"
}
-->

# WKInterfaceSwitch

An interface element that toggles between an On and Off state.

```
class WKInterfaceSwitch
```

## Overview

Switches are commonly used to indicate whether a feature is enabled or disabled. You set the initial value of the switch in your storyboard file, but you can modify that value at runtime using the methods of this class.

Do not subclass or create instances of this class yourself. Instead, define outlets in your interface controller class and connect them to the corresponding objects in your storyboard file. For example, to refer to a switch object in your interface, define a property with the following syntax in your interface controller class:

```swift
@IBOutlet weak var mySwitch: WKInterfaceSwitch!
```

During the initialization of your interface controller, WatchKit creates a new instance of this class and assigns it to your outlet. At that point, you can use the object in your outlet to make changes to the onscreen switch.

When the user changes the value of a switch, WatchKit delivers the new value to the slider’s action method. The format of a switch’s action method is as follows:

```swift
@IBAction func switchAction(value: Bool)
```

Declare a method of this form in the interface controller class used to manage the switch. You can change the method name to anything you like. When configuring the switch in Xcode, connect its selector to your custom action method.

### Interface Builder Configuration Options

Xcode lets you configure information about switches in your storyboard file. The following table lists the attributes you can configure and their meaning.

|Attribute|Description                                                                                                                                                                                                                                                                                             |
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|State    |The initial state of the switch. The switch can be off or on. You can modify the state of the switch programmatically at runtime using the ``doc://com.apple.watchkit/documentation/WatchKit/WKInterfaceSwitch/setOn(_:)`` method.                                                                      |
|Tint     |The color of the switch when it is in the on state.                                                                                                                                                                                                                                                     |
|Enabled  |A checkbox indicating whether the switch is enabled. An enabled switch calls its action method when the user changes the state of the switch. You can enable or disable a switch programmatically using the ``doc://com.apple.watchkit/documentation/WatchKit/WKInterfaceSwitch/setEnabled(_:)`` method.|
|Title    |The string to be displayed next to the switch. If specified, the title string is displayed next to the switch.                                                                                                                                                                                          |
|Color    |The text color for the switch’s title string. You can also set the switch color using the ``doc://com.apple.watchkit/documentation/WatchKit/WKInterfaceSwitch/setColor(_:)`` method.                                                                                                                    |
|Font     |The font information to be applied to the title string. You can specify one of the predefined styles or provide custom style information.                                                                                                                                                               |

## Topics

### Setting the Switch’s Title

[`-  setTitle:`](/documentation/WatchKit/WKInterfaceSwitch/setTitle(_:))

Sets the switch title to the specified string.

[`-  setAttributedTitle:`](/documentation/WatchKit/WKInterfaceSwitch/setAttributedTitle(_:))

Sets the switch title to the specified attributed string.

### Configuring the Switch

[`-  setOn:`](/documentation/WatchKit/WKInterfaceSwitch/setOn(_:))

Sets the state of the switch to the specified value.

[`-  setColor:`](/documentation/WatchKit/WKInterfaceSwitch/setColor(_:))

Changes the tint color of the switch when it is on.

### Enabling the Switch

[`-  setEnabled:`](/documentation/WatchKit/WKInterfaceSwitch/setEnabled(_:))

Enables or disables the switch.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`WKInterfaceObject`](/documentation/WatchKit/WKInterfaceObject)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)