<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIControl",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIControl"
  },
  "title" : "UIControl"
}
-->

# UIControl

The base class for controls, which are visual elements that convey a specific action or intention in response to user interactions.

```
@MainActor class UIControl
```

## Overview

Controls implement elements such as buttons and sliders, which your app can use to facilitate navigation, gather user input, or manipulate content. Controls use the target-action mechanism to report user interactions to your app.

![Examples of UIKit controls.](images/com.apple.uikit/media-1965830@2x.png)

You don’t create instances of this class directly. The [`UIControl`](/documentation/UIKit/UIControl) class is a subclassing point that you extend to implement custom controls. You can also subclass existing control classes to extend or modify their behaviors. For example, you might override the methods of this class to track touch events yourself or to determine when the state of the control changes.

A control’s state determines its appearance and its ability to support user interactions. Controls can be in one of several states, which the [`UIControl.State`](/documentation/UIKit/UIControl/State-swift.struct) type defines. You can change the state of a control programmatically according to your app’s needs. For example, you might disable a control to prevent the user from interacting with it. User interactions can also change the state of a control.

### Respond to user interaction

The target-action mechanism simplifies the code that you write to use controls in your app. Instead of writing code to track touch events, you write action methods to respond to control-specific events. For example, you might write an action method that responds to changes in the value of a slider. The control handles all the work of tracking incoming touch events and determining when to call your methods.

When adding an action method to a control, you specify both the action method and an object that defines that method to the [`addTarget(_:action:for:)`](/documentation/UIKit/UIControl/addTarget(_:action:for:)) method. (You can also configure the target and action of a control in Interface Builder.) The target object can be any object, but it’s typically the view controller’s root view that contains the control. If you specify `nil` for the target object, the control searches the responder chain for an object that defines the specified action method.

The signature of an action method takes one of three forms. The `sender` parameter corresponds to the control that calls the action method, and the `event` parameter corresponds to the [`UIEvent`](/documentation/UIKit/UIEvent) object that triggered the control-related event.

```objc
- (IBAction)doSomething;
- (IBAction)doSomething:(id)sender;
- (IBAction)doSomething:(id)sender forEvent:(UIEvent*)event;
```

The system calls action methods when the user interacts with the control in specific ways. The [`UIControl.Event`](/documentation/UIKit/UIControl/Event) type defines the types of user interactions that a control can report and those interactions mostly correlate to specific touch events within the control. When configuring a control, you must specify which events trigger the calling of your method. For a button control, you might use the [`touchDown`](/documentation/UIKit/UIControl/Event/touchDown) or [`touchUpInside`](/documentation/UIKit/UIControl/Event/touchUpInside) event to trigger calls to your action method. For a slider, you might care only about changes to the slider’s value, so you might choose to attach your action method to [`valueChanged`](/documentation/UIKit/UIControl/Event/valueChanged) events.

When a control-specific event occurs, the control calls any associated action methods immediately. The current [`UIApplication`](/documentation/UIKit/UIApplication) object dispatches action methods and finds an appropriate object to handle the message, following the responder chain, if necessary. For more information about responders and the responder chain, see [Event Handling Guide for UIKit Apps](https://developer.apple.com/library/archive/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/index.html#//apple_ref/doc/uid/TP40009541).

### Configure control attributes in Interface Builder

The following table lists the attributes for instances of the [`UIControl`](/documentation/UIKit/UIControl) class.

|Attribute|Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|Alignment|The horizontal and vertical alignment of a control’s content. For controls that contain text or images, such as buttons and text fields, use these attributes to configure the position of that content within the control’s bounds. ![](spacer) These alignment options apply to the content of a control and not to the control itself. For information about how to align controls with respect to other controls and views, see [Auto Layout Guide](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/index.html#//apple_ref/doc/uid/TP40010853).|
|Content  |The initial state of the control. Use the checkboxes to configure whether the control is in an enabled, selected, or highlighted state initially.                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### Support localization

Because [`UIControl`](/documentation/UIKit/UIControl) is an abstract class, you don’t internationalize it specifically. However, you do internationalize the content of subclasses like [`UIButton`](/documentation/UIKit/UIButton). For information about internationalizing a specific control, see the reference for that control.

### Make controls accessible

Controls are accessible by default. To be useful, an accessible user interface element must provide accurate and helpful information about its screen position, name, behavior, value, and type. This is the information VoiceOver speaks to users. Users who are blind or have low vision can rely on VoiceOver to help them use their devices.

Controls support the following accessibility attributes:

- **Label.** A short, localized word or phrase that succinctly describes the control or view, but doesn’t identify the element’s type. Examples are *Add* and *Play*.
- **Traits.** A combination of one or more individual traits, each of which describes a single aspect of an element’s state, behavior, or usage. For example, you might use a combination of the Keyboard Key and the Selected traits to describe an element that behaves like a keyboard key and that’s in a selected state.
- **Hint.** A brief, localized phrase that describes the results of an action on an element. Examples are *Adds a title* and *Opens the shopping list*.
- **Frame.** The frame of the element in screen coordinates, which the `CGRect` structure specifies for an element’s screen location and size.
- **Value.** The current value of an element when the label doesn’t represent the value. For example, the label for a slider might be *Speed*, but its current value might be *50%*.

The `UIControl` class provides default content for the value and frame attributes. Many controls automatically enable additional specific traits as well. You can configure other accessibility attributes programmatically or with the Identity inspector in Interface Builder.

For more information about accessibility attributes, see [Accessibility Programming Guide for iOS](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/iPhoneAccessibility/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008785).

### Subclassing notes

Subclassing [`UIControl`](/documentation/UIKit/UIControl) gives you access to the built-in target-action mechanism and simplified event-handling support. You can subclass existing controls and modify their behavior in one of two ways:

- Override the ``doc://com.apple.uikit/documentation/UIKit/UIControl/sendAction(_:to:for:)`` method of an existing subclass to observe or modify the dispatching of action methods to the control’s associated targets. You might use this method to modify the dispatch behavior for the specified object, selector, or event.
- Override the ``doc://com.apple.uikit/documentation/UIKit/UIControl/beginTracking(_:with:)``, ``doc://com.apple.uikit/documentation/UIKit/UIControl/continueTracking(_:with:)``, ``doc://com.apple.uikit/documentation/UIKit/UIControl/endTracking(_:with:)``, and ``doc://com.apple.uikit/documentation/UIKit/UIControl/cancelTracking(with:)`` methods to track touch events occurring in the control. You can use the tracking information to perform additional actions. Always use these methods to track touch events instead of the methods that the ``doc://com.apple.uikit/documentation/UIKit/UIResponder`` class defines.

If you subclass [`UIControl`](/documentation/UIKit/UIControl) directly, your subclass is responsible for setting up and managing your control’s visual appearance. Use the methods for tracking events to update your control’s state and to send an action when the control’s value changes.

## Topics

### Creating a control

[`init(frame:primaryAction:)`](/documentation/UIKit/UIControl/init(frame:primaryAction:))

Creates a control with the specified frame and primary action.

[`init(frame:)`](/documentation/UIKit/UIControl/init(frame:))

Creates a control with the specified frame.

[`init(coder:)`](/documentation/UIKit/UIControl/init(coder:))

Creates a control from data in an unarchiver.

### Managing state

[`state`](/documentation/UIKit/UIControl/state-swift.property)

The state of the control, specified as a bit mask value.

[`UIControl.State`](/documentation/UIKit/UIControl/State-swift.struct)

Constants describing the state of a control.

[`isEnabled`](/documentation/UIKit/UIControl/isEnabled)

A Boolean value indicating whether the control is in the enabled state.

[`isSelected`](/documentation/UIKit/UIControl/isSelected)

A Boolean value indicating whether the control is in the selected state.

[`isHighlighted`](/documentation/UIKit/UIControl/isHighlighted)

A Boolean value indicating whether the control draws a highlight.

### Specifying content alignment

[`contentVerticalAlignment`](/documentation/UIKit/UIControl/contentVerticalAlignment-swift.property)

The vertical alignment of content within the control’s bounds.

[`UIControl.ContentVerticalAlignment`](/documentation/UIKit/UIControl/ContentVerticalAlignment-swift.enum)

Constants for specifying the vertical alignment of content (text and images) in a control.

[`contentHorizontalAlignment`](/documentation/UIKit/UIControl/contentHorizontalAlignment-swift.property)

The horizontal alignment of content within the control’s bounds.

[`effectiveContentHorizontalAlignment`](/documentation/UIKit/UIControl/effectiveContentHorizontalAlignment)

The horizontal alignment currently in effect for the control.

[`UIControl.ContentHorizontalAlignment`](/documentation/UIKit/UIControl/ContentHorizontalAlignment-swift.enum)

The horizontal alignment of content (text and images) within a control.

### Managing the control’s targets and actions

[`addTarget(_:action:for:)`](/documentation/UIKit/UIControl/addTarget(_:action:for:))

Associates a target object and action method with the control.

[`removeTarget(_:action:for:)`](/documentation/UIKit/UIControl/removeTarget(_:action:for:))

Stops the delivery of events to the specified target object.

[`allTargets`](/documentation/UIKit/UIControl/allTargets)

Returns all target objects associated with the control.

[`addAction(_:for:)`](/documentation/UIKit/UIControl/addAction(_:for:))

Adds the UIAction to a given event. UIActions are uniqued based on their identifier, and subsequent actions with the same identifier replace previously added actions. You may add multiple UIActions for corresponding controlEvents, and you may add the same action to multiple controlEvents.

[`removeAction(_:for:)`](/documentation/UIKit/UIControl/removeAction(_:for:))

Removes the action from the set of passed control events.

[`removeAction(identifiedBy:for:)`](/documentation/UIKit/UIControl/removeAction(identifiedBy:for:))

Removes the action with the provided identifier from the set of passed control events.

[`actions(forTarget:forControlEvent:)`](/documentation/UIKit/UIControl/actions(forTarget:forControlEvent:))

Returns the actions performed on a target object when the specified event occurs.

[`allControlEvents`](/documentation/UIKit/UIControl/allControlEvents)

Returns the events for which the control has associated actions.

[`enumerateEventHandlers(_:)`](/documentation/UIKit/UIControl/enumerateEventHandlers(_:))

[`enumerateEventHandlers:`](/documentation/UIKit/UIControl/enumerateEventHandlers:)

Iterate over the event handlers installed on this control at the time this method is called. For each call, either actionHandler or action will be non-nil. controlEvents is always non-zero. Setting *stop to YES will terminate the enumeration early. It is legal to manipulate the control’s event handlers within the block.

[`UIControl.Event`](/documentation/UIKit/UIControl/Event)

Constants describing the types of events possible for controls.

### Triggering actions

[`performPrimaryAction()`](/documentation/UIKit/UIControl/performPrimaryAction())

Calls the method associated with the control’s primary action.

[`sendAction(_:)`](/documentation/UIKit/UIControl/sendAction(_:))

Like -sendAction:to:forEvent:, this method is called by -sendActionsForControlEvents:. You may override this method to observe or modify behavior. If you override this method, you should call super precisely once to dispatch the action, or not call super to suppress sending that action.

[`sendAction(_:to:for:)`](/documentation/UIKit/UIControl/sendAction(_:to:for:))

Calls the specified action method.

[`sendActions(for:)`](/documentation/UIKit/UIControl/sendActions(for:))

Calls the action methods associated with the specified events.

### Tracking touches and redrawing controls

[`beginTracking(_:with:)`](/documentation/UIKit/UIControl/beginTracking(_:with:))

Notifies the control when a touch event enters the control’s bounds.

[`continueTracking(_:with:)`](/documentation/UIKit/UIControl/continueTracking(_:with:))

Notifies the control when a touch event for the control updates.

[`endTracking(_:with:)`](/documentation/UIKit/UIControl/endTracking(_:with:))

Notifies the control when a touch event associated with the control ends.

[`cancelTracking(with:)`](/documentation/UIKit/UIControl/cancelTracking(with:))

Notifies the control to cancel tracking related to the specified event.

[`isTracking`](/documentation/UIKit/UIControl/isTracking)

A Boolean value that indicates whether the control is currently tracking touch events.

[`isTouchInside`](/documentation/UIKit/UIControl/isTouchInside)

A Boolean value that indicates whether a tracked touch event is currently inside the control’s bounds.

### Managing context menus

[Adding context menus in your app](/documentation/UIKit/adding-context-menus-in-your-app)

Provide quick access to useful actions by adding context menus to your iOS app.

[`contextMenuInteraction`](/documentation/UIKit/UIControl/contextMenuInteraction)

A context menu interaction for the control.

[`isContextMenuInteractionEnabled`](/documentation/UIKit/UIControl/isContextMenuInteractionEnabled)

A Boolean value that determines whether the control enables its context menu interaction.

[`showsMenuAsPrimaryAction`](/documentation/UIKit/UIControl/showsMenuAsPrimaryAction)

A Boolean value that determines whether the context menu interaction is the control’s primary action.

[`contextMenuInteraction(_:configurationForMenuAtLocation:)`](/documentation/UIKit/UIControl/contextMenuInteraction(_:configurationForMenuAtLocation:))

[`contextMenuInteraction(_:previewForDismissingMenuWithConfiguration:)`](/documentation/UIKit/UIControl/contextMenuInteraction(_:previewForDismissingMenuWithConfiguration:))

[`contextMenuInteraction(_:previewForHighlightingMenuWithConfiguration:)`](/documentation/UIKit/UIControl/contextMenuInteraction(_:previewForHighlightingMenuWithConfiguration:))

[`contextMenuInteraction(_:willDisplayMenuFor:animator:)`](/documentation/UIKit/UIControl/contextMenuInteraction(_:willDisplayMenuFor:animator:))

[`contextMenuInteraction(_:willEndFor:animator:)`](/documentation/UIKit/UIControl/contextMenuInteraction(_:willEndFor:animator:))

[`menuAttachmentPoint(for:)`](/documentation/UIKit/UIControl/menuAttachmentPoint(for:))

Return a point in this control’s coordinate space to which to attach the given configuration’s menu.

### Showing tooltips

Show tooltips in your iPhone and iPad apps running on a Mac with Apple silicon, or your app built with Mac Catalyst.

[`toolTip`](/documentation/UIKit/UIControl/toolTip)

The default text to display in the control’s tooltip.

[`toolTipInteraction`](/documentation/UIKit/UIControl/toolTipInteraction)

The tooltip interaction associated with the control.

### Inspecting animation status

[`isSymbolAnimationEnabled`](/documentation/UIKit/UIControl/isSymbolAnimationEnabled)

A Boolean value that indicates whether symbol effects animate.



---

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)
