A control that offers a binary choice, such as On/Off.
SDKs
- iOS 2.0+
- Mac Catalyst 13.0+
Framework
- UIKit
Declaration
@interface UISwitch : UIControl
Overview
The UISwitch
class declares a property and a method to control its on/off state. As with UISlider
, when the user manipulates the switch control (“flips” it) a UIControl
event is generated, which results in the control (if properly configured) sending an action message.
You can customize the appearance of the switch by changing the color used to tint the switch when it is on or off.
For information about basic view behaviors, see View Programming Guide for iOS.