UIControlState
UIControlState is a bitmask type used by UIControl and its subclasses to describe the current state of a control, such as a button. It is used by the system to determine appearance and behavior in response to user interactions. In Objective-C, UIControlState is defined as an NS_OPTIONS value, enabling multiple states to be stored in a single variable. In Swift, the equivalent is UIControl.State, an OptionSet.
States can be combined. A control may be in more than one state at once, though some
- Normal: the default state when no other state applies.
- Highlighted: during touch-down or pressing, often used to show a pressed look.
- Disabled: when the control is not interactive, usually dimmed.
- Selected: when a control is chosen or toggled on.
- Focused: relevant on tvOS and devices with focus-based navigation.
- Application and Reserved: internal or future-use states.
UIControlState is used by APIs that customize appearance for specific states, such as setTitle:forState:, setImage:forState:, or
The focus state is particularly pertinent on tvOS. Application and Reserved are intended for internal use