UIControlEvents
UIControlEvents are part of the UIKit framework used in iOS development to represent the various user interactions that can occur with UIControl objects, such as buttons, switches, sliders, and text fields. In Swift, UIControl.World UIControl.Event is an option set built around raw UInt values, allowing multiple events to be combined using the bitwise OR operator. In Objective‑C, the equivalent enumeration is UIControlEvents, defined as a typedef of NS_OPTIONS with values like UIControlEventTouchUpInside, UIControlEventValueChanged, and UIControlEventEditingChanged.
• UIControlEventTouchDown – the user touches the control and it has not moved off its bounds.
• UIControlEventTouchUpInside – the user lifts a finger while still inside the control bounds, commonly used to trigger
• UIControlEventTouchUpOutside – lift occurs outside the control bounds.
• UIControlEventValueChanged – state or value of the control changes, e.g., a UISlider adjusts its value.
• UIControlEventEditingChanged – used with text fields to detect live input changes.
• UIControlEventAllEvents – a catch‑all constant for testing or debugging.
To respond to an event, a target-action pair is registered with addTarget(_:action:for:) on the UIControl. The
Because UIControlEvents are option sets, developers can combine them for concise code, for example UIControlEventTouchUpInside | UIControlEventTouchUpOutside.