Instance Method


Set the state of the switch to On or Off, optionally animating the transition.


func setOn(_ on: Bool, animated: Bool)



true if the switch should be turned to the On position; false if it should be turned to the Off position. If the switch is already in the designated position, nothing happens.


true to animate the “flipping” of the switch; otherwise false.


Setting the switch to either position does not result in an action message being sent.

See Also

Setting the Off/On State

var isOn: Bool

A Boolean value that determines the off/on state of the switch.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software