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

# UIView

An object that manages the content for a rectangular area on the screen.

```
@MainActor class UIView
```

## Overview

Views are the fundamental building blocks of your app’s user interface, and the [`UIView`](/documentation/UIKit/UIView) class defines the behaviors that are common to all views. A view object renders content within its bounds rectangle, and handles any interactions with that content. The [`UIView`](/documentation/UIKit/UIView) class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content. To display labels, images, buttons, and other interface elements commonly found in apps, use the view subclasses that the UIKit framework provides rather than trying to define your own.

Because view objects are the main way your application interacts with the user, they have a number of responsibilities. Here are just a few:

- Drawing and animation
  - Views draw content in their rectangular area using UIKit or Core Graphics.
  - You can animate some view properties to new values.
- Layout and subview management
  - Views may contain zero or more subviews.
  - Views can adjust the size and position of their subviews.
  - Use Auto Layout to define the rules for resizing and repositioning your views in response to changes in the view hierarchy.
- Event handling
  - A view is a subclass of [`UIResponder`](/documentation/UIKit/UIResponder) and can respond to touches and other types of events.
  - Views can install gesture recognizers to handle common gestures.

Views can nest inside other views to create view hierarchies, which offer a convenient way to organize related content. Nesting a view creates a parent-child relationship between the nested child view (known as the *subview*) and the parent (known as the *superview*). A parent view may contain any number of subviews, but each subview has only one superview. By default, when a subview’s visible area extends outside of the bounds of its superview, no clipping of the subview’s content occurs. Use the [`clipsToBounds`](/documentation/UIKit/UIView/clipsToBounds) property to change that behavior.

The [`frame`](/documentation/UIKit/UIView/frame) and [`bounds`](/documentation/UIKit/UIView/bounds) properties define the geometry of each view. The [`frame`](/documentation/UIKit/UIView/frame) property defines the origin and dimensions of the view in the coordinate system of its superview. The [`bounds`](/documentation/UIKit/UIView/bounds) property defines the internal dimensions of the view as it sees them, and its use is almost exclusive to custom drawing code. The center property provides a convenient way to reposition a view without changing its [`frame`](/documentation/UIKit/UIView/frame) or [`bounds`](/documentation/UIKit/UIView/bounds) properties directly.

### Create a view

Normally, you create views in your storyboards by dragging them from the library to your canvas. You can also create views programmatically. When creating a view, you typically specify its initial size and position relative to its future superview. For example, the following example creates a view and places its top-left corner at the point (10, 10) in the superview’s coordinate system (once it is added to that superview).

```objc
CGRect  viewRect = CGRectMake(10, 10, 100, 100);
UIView* myView = [[UIView alloc] initWithFrame:viewRect];
```

To add a subview to another view, call the [`addSubview(_:)`](/documentation/UIKit/UIView/addSubview(_:)) method on the superview. You may add any number of subviews to a view, and sibling views may overlap each other without any issues in iOS. Each call to the [`addSubview(_:)`](/documentation/UIKit/UIView/addSubview(_:)) method places the new view on top of all other siblings. You can specify the relative z-order of subview by adding it using the [`insertSubview(_:aboveSubview:)`](/documentation/UIKit/UIView/insertSubview(_:aboveSubview:)) and [`insertSubview(_:belowSubview:)`](/documentation/UIKit/UIView/insertSubview(_:belowSubview:)) methods. You can also exchange the position of already added subviews using the [`exchangeSubview(at:withSubviewAt:)`](/documentation/UIKit/UIView/exchangeSubview(at:withSubviewAt:)) method.

After creating a view, create Auto Layout rules to govern how the size and position of the view change in response to changes in the rest of the view hierarchy.

### Draw views

View drawing occurs on an as-needed basis. When a view is first shown, or when all or part of it becomes visible due to layout changes, the system asks the view to draw its contents. For views that contain custom content using UIKit or Core Graphics, the system calls the view’s [`draw(_:)`](/documentation/UIKit/UIView/draw(_:)) method. Your implementation of this method is responsible for drawing the view’s content into the current graphics context, which is set up by the system automatically prior to calling this method. This creates a static visual representation of your view’s content that can then be displayed on the screen.

When the actual content of your view changes, it’s your responsibility to notify the system that your view needs to be redrawn. You do this by calling your view’s [`setNeedsDisplay()`](/documentation/UIKit/UIView/setNeedsDisplay()) or [`setNeedsDisplay(_:)`](/documentation/UIKit/UIView/setNeedsDisplay(_:)) method of the view. These methods let the system know that it should update the view during the next drawing cycle. Because it waits until the next drawing cycle to update the view, you can call these methods on multiple views to update them at the same time.

### Animate views

Changes to several view properties can be animated — that is, changing the property creates an animation starting at the current value and ending at the new value that you specify. The following properties of the [`UIView`](/documentation/UIKit/UIView) class are animatable:

- [`frame`](/documentation/UIKit/UIView/frame)
- [`bounds`](/documentation/UIKit/UIView/bounds)
- [`center`](/documentation/UIKit/UIView/center)
- [`transform`](/documentation/UIKit/UIView/transform)
- [`alpha`](/documentation/UIKit/UIView/alpha)
- [`backgroundColor`](/documentation/UIKit/UIView/backgroundColor)

To animate your changes, create a [`UIViewPropertyAnimator`](/documentation/UIKit/UIViewPropertyAnimator) object and use its handler block to change the values of your view’s properties. The [`UIViewPropertyAnimator`](/documentation/UIKit/UIViewPropertyAnimator) class lets you specify the duration and timing of your animations, but it performs the actual animations. You can pause a property-based animator that’s currently running to interrupt the animation and drive it interactively. For more information, see [`UIViewPropertyAnimator`](/documentation/UIKit/UIViewPropertyAnimator).

### Threading considerations

Manipulations to your app’s user interface must occur on the main thread. Thus, you should always call the methods of the [`UIView`](/documentation/UIKit/UIView) class from code running in the main thread of your app. The only time this may not be strictly necessary is when creating the view object itself, but all other manipulations should occur on the main thread.

### Subclassing notes

The [`UIView`](/documentation/UIKit/UIView) class is a key subclassing point for visual content that also requires user interactions. Although there are many good reasons to subclass [`UIView`](/documentation/UIKit/UIView), it is recommended that you do so only when the basic [`UIView`](/documentation/UIKit/UIView) class or the standard system views do not provide the capabilities that you need. Subclassing requires more work on your part to implement the view and to tune its performance.

For information about ways to avoid subclassing, see [`Alternatives to subclassing`](/documentation/UIKit/UIView#Alternatives-to-subclassing).

#### Methods to override

When subclassing [`UIView`](/documentation/UIKit/UIView), there are only a handful of methods you should override and many methods that you might override depending on your needs. Because [`UIView`](/documentation/UIKit/UIView) is a highly configurable class, there are also many ways to implement sophisticated view behaviors without overriding custom methods, which are discussed in the Alternatives to Subclassing section. In the meantime, the following list includes the methods you might consider overriding in your [`UIView`](/documentation/UIKit/UIView) subclasses:

- Initialization:
  - [`init(frame:)`](/documentation/UIKit/UIView/init(frame:)) - It is recommended that you implement this method. You can also implement custom initialization methods in addition to, or instead of, this method.
  - [`init(coder:)`](/documentation/UIKit/UIView/init(coder:)) - Implement this method if you load your view from storyboards or nib files and your view requires custom initialization.
  - [`layerClass`](/documentation/UIKit/UIView/layerClass) Use this property only if you want your view to use a different Core Animation layer for its backing store. For example, if your view uses tiling to display a large scrollable area, you might want to set the property to the <doc://com.apple.documentation/documentation/QuartzCore/CATiledLayer> class.
- Drawing and printing:
  - [`draw(_:)`](/documentation/UIKit/UIView/draw(_:)) - Implement this method if your view draws custom content. If your view does not do any custom drawing, avoid overriding this method.
  - [`draw(_:for:)`](/documentation/UIKit/UIView/draw(_:for:)) - Implement this method only if you want to draw your view’s content differently during printing.
- Layout and Constraints:
  - [`requiresConstraintBasedLayout`](/documentation/UIKit/UIView/requiresConstraintBasedLayout) Use this property if your view class requires constraints to work properly.
  - [`updateConstraints()`](/documentation/UIKit/UIView/updateConstraints()) - Implement this method if your view needs to create custom constraints between your subviews.
  - [`alignmentRect(forFrame:)`](/documentation/UIKit/UIView/alignmentRect(forFrame:)), [`frame(forAlignmentRect:)`](/documentation/UIKit/UIView/frame(forAlignmentRect:)) - Implement these methods to override how your views are aligned to other views.
  - [`didAddSubview(_:)`](/documentation/UIKit/UIView/didAddSubview(_:)), [`willRemoveSubview(_:)`](/documentation/UIKit/UIView/willRemoveSubview(_:)) - Implement these methods as needed to track the additions and removals of subviews.
  - [`willMove(toSuperview:)`](/documentation/UIKit/UIView/willMove(toSuperview:)), [`didMoveToSuperview()`](/documentation/UIKit/UIView/didMoveToSuperview()) - Implement these methods as needed to track the movement of the current view in your view hierarchy.
- Event Handling:
  - [`gestureRecognizerShouldBegin(_:)`](/documentation/UIKit/UIView/gestureRecognizerShouldBegin(_:)) - Implement this method if your view handles touch events directly and might want to prevent attached gesture recognizers from triggering additional actions.
  - [`touchesBegan(_:with:)`](/documentation/UIKit/UIResponder/touchesBegan(_:with:)), [`touchesMoved(_:with:)`](/documentation/UIKit/UIResponder/touchesMoved(_:with:)), [`touchesEnded(_:with:)`](/documentation/UIKit/UIResponder/touchesEnded(_:with:)), [`touchesCancelled(_:with:)`](/documentation/UIKit/UIResponder/touchesCancelled(_:with:)) - Implement these methods if you need to handle touch events directly. (For gesture-based input, use gesture recognizers.)

#### Alternatives to subclassing

Many view behaviors can be configured without the need for subclassing. Before you start overriding methods, consider whether modifying the following properties or behaviors would provide the behavior you need.

- [`addConstraint(_:)`](/documentation/UIKit/UIView/addConstraint(_:)) - Define automatic layout behavior for the view and its subviews.
- [`autoresizingMask`](/documentation/UIKit/UIView/autoresizingMask-swift.property) - Provides automatic layout behavior when the superview’s frame changes. These behaviors can be combined with constraints.
- [`contentMode`](/documentation/UIKit/UIView/contentMode-swift.property) - Provides layout behavior for the view’s content, as opposed to the [`frame`](/documentation/UIKit/UIView/frame) of the view. This property also affects how the content is scaled to fit the view and whether it is cached or redrawn.
- [`isHidden`](/documentation/UIKit/UIView/isHidden) or [`alpha`](/documentation/UIKit/UIView/alpha) - Change the transparency of the view as a whole rather than hiding or applying alpha to your view’s rendered content.
- [`backgroundColor`](/documentation/UIKit/UIView/backgroundColor) - Set the view’s color rather than drawing that color yourself.
- Subviews - Rather than draw your content using a [`draw(_:)`](/documentation/UIKit/UIView/draw(_:)) method, embed image and label subviews with the content you want to present.
- Gesture recognizers - Rather than subclass to intercept and handle touch events yourself, you can use gesture recognizers to send an action to a target object.
- Animations - Use the built-in animation support rather than trying to animate changes yourself. The animation support provided by Core Animation is fast and easy to use.
- Image-based backgrounds - For views that display relatively static content, consider using a [`UIImageView`](/documentation/UIKit/UIImageView) object with gesture recognizers instead of subclassing and drawing the image yourself. Alternatively, you can also use a generic [`UIView`](/documentation/UIKit/UIView) object and assign your image as the content of the view’s <doc://com.apple.documentation/documentation/QuartzCore/CALayer> object.

Animations are another way to make visible changes to a view without requiring you to subclass and implement complex drawing code. Many properties of the [`UIView`](/documentation/UIKit/UIView) class are animatable, which means changes to those properties can trigger system-generated animations. Starting animations requires as little as one line of code to indicate that any changes that follow should be animated. For more information about animation support for views, see [`Animate views`](/documentation/UIKit/UIView#Animate-views).

### Sensor coordinate orientation

`UIView` conforms to <doc://com.apple.documentation/documentation/CoreLocation/CLBodyIdentifiable> and <doc://com.apple.documentation/documentation/CoreMotion/CMBodyIdentifiable>, informing Core Location and Core Motion how the app’s UI and this view are situated with respect to reference physical orientations. They use this information to transform the sensor values they provide, such as compass headings and device motion data, so those values align with your UI’s actual orientation. Without this association, Core Location and Core Motion report sensor values relative to the device’s physical orientation, which can produce unexpected results, such as a navigation map that appears rotated.

To use this approach, set any view as the body on a `CLLocationManager` or `CMMotionManager` instance. The system tracks orientation changes through the view and applies the correct transformation automatically.

```swift
let motionManager = CMMotionManager()

override func viewDidLoad() {
    super.viewDidLoad()
    motionManager.deviceMotionBody = view
}
```

## Topics

### Creating a view object

[`init(frame: CGRect)`](/documentation/UIKit/UIView/init(frame:))

Creates a view with the specified frame rectangle.

[`init?(coder: NSCoder)`](/documentation/UIKit/UIView/init(coder:))

Creates a view from data in an unarchiver.

### Configuring a view’s visual appearance

[`var backgroundColor: UIColor?`](/documentation/UIKit/UIView/backgroundColor)

The view’s background color.

[`var isHidden: Bool`](/documentation/UIKit/UIView/isHidden)

A Boolean value that determines whether the view is hidden.

[`var alpha: CGFloat`](/documentation/UIKit/UIView/alpha)

The view’s alpha value.

[`var isOpaque: Bool`](/documentation/UIKit/UIView/isOpaque)

A Boolean value that determines whether the view is opaque.

[`var tintColor: UIColor!`](/documentation/UIKit/UIView/tintColor)

The first nondefault tint color value in the view’s hierarchy, ascending from and starting with the view itself.

[`var tintAdjustmentMode: UIView.TintAdjustmentMode`](/documentation/UIKit/UIView/tintAdjustmentMode-swift.property)

The first non-default tint adjustment mode value in the view’s hierarchy, ascending from and starting with the view itself.

[`var clipsToBounds: Bool`](/documentation/UIKit/UIView/clipsToBounds)

A Boolean value that determines whether subviews are confined to the bounds of the view.

[`var clearsContextBeforeDrawing: Bool`](/documentation/UIKit/UIView/clearsContextBeforeDrawing)

A Boolean value that determines whether the view’s bounds should be automatically cleared before drawing.

[`var mask: UIView?`](/documentation/UIKit/UIView/mask)

An optional view whose alpha channel is used to mask a view’s content.

[`class var layerClass: AnyClass`](/documentation/UIKit/UIView/layerClass)

Returns the class used to create the layer for instances of this class.

[`var layer: CALayer`](/documentation/UIKit/UIView/layer)

The view’s Core Animation layer to use for rendering.

### Configuring a view’s corners

[`var cornerConfiguration: UICornerConfiguration`](/documentation/UIKit/UIView/cornerConfiguration-7l0ja)

A configuration that defines the corners of the view.

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

A configuration that defines how corner radii are mapped to the corners of a rectangle.

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

A type that represents the radius the system uses to round a corner.

[`@property (nonatomic, copy, nonnull) UICornerConfiguration * cornerConfiguration;`](/documentation/UIKit/UIView/cornerConfiguration-3m8ya)

A configuration that defines the corners of the view.

[`@interface UICornerConfiguration : NSObject`](/documentation/UIKit/UICornerConfiguration-c.class)

A configuration that defines how corner radii are mapped to the corners of a rectangle.

[`@interface UICornerRadius : NSObject`](/documentation/UIKit/UICornerRadius-c.class)

A type that represents the radius the system uses to round a corner.

[`func effectiveRadius(corner: UIRectCorner) -> CGFloat`](/documentation/UIKit/UIView/effectiveRadius(corner:))

Returns the effective radius for the corner you provide, calculated using the view’s current corner configuration.

### Configuring the event-related behavior

[`var isUserInteractionEnabled: Bool`](/documentation/UIKit/UIView/isUserInteractionEnabled)

A Boolean value that determines whether user events are ignored and removed from the event queue.

[`var isMultipleTouchEnabled: Bool`](/documentation/UIKit/UIView/isMultipleTouchEnabled)

A Boolean value that indicates whether the view receives more than one touch at a time.

[`var isExclusiveTouch: Bool`](/documentation/UIKit/UIView/isExclusiveTouch)

A Boolean value that indicates whether the receiver handles touch events exclusively.

### Configuring the bounds and frame rectangles

[`var frame: CGRect`](/documentation/UIKit/UIView/frame)

The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.

[`var bounds: CGRect`](/documentation/UIKit/UIView/bounds)

The bounds rectangle, which describes the view’s location and size in its own coordinate system.

[`var center: CGPoint`](/documentation/UIKit/UIView/center)

The center point of the view’s frame rectangle.

[`var transform: CGAffineTransform`](/documentation/UIKit/UIView/transform)

Specifies the transform applied to the view, relative to the center of its bounds.

[`var transform3D: CATransform3D`](/documentation/UIKit/UIView/transform3D)

The three-dimensional transform to apply to the view.

[`var anchorPoint: CGPoint`](/documentation/UIKit/UIView/anchorPoint)

The anchor point of the view’s bounds rectangle.

### Managing the view hierarchy

[`var superview: UIView?`](/documentation/UIKit/UIView/superview)

The receiver’s superview, or `nil` if it has none.

[`var subviews: [UIView]`](/documentation/UIKit/UIView/subviews)

The receiver’s immediate subviews.

[`var window: UIWindow?`](/documentation/UIKit/UIView/window)

The receiver’s window object, or `nil` if it has none.

[`func addSubview(UIView)`](/documentation/UIKit/UIView/addSubview(_:))

Adds a view to the end of the receiver’s list of subviews.

[`func bringSubviewToFront(UIView)`](/documentation/UIKit/UIView/bringSubviewToFront(_:))

Moves the specified subview so that it appears on top of its siblings.

[`func sendSubviewToBack(UIView)`](/documentation/UIKit/UIView/sendSubviewToBack(_:))

Moves the specified subview so that it appears behind its siblings.

[`func removeFromSuperview()`](/documentation/UIKit/UIView/removeFromSuperview())

Unlinks the view from its superview and its window, and removes it from the responder chain.

[`func insertSubview(UIView, at: Int)`](/documentation/UIKit/UIView/insertSubview(_:at:))

Inserts a subview at the specified index.

[`func insertSubview(UIView, aboveSubview: UIView)`](/documentation/UIKit/UIView/insertSubview(_:aboveSubview:))

Inserts a view above another view in the view hierarchy.

[`func insertSubview(UIView, belowSubview: UIView)`](/documentation/UIKit/UIView/insertSubview(_:belowSubview:))

Inserts a view below another view in the view hierarchy.

[`func exchangeSubview(at: Int, withSubviewAt: Int)`](/documentation/UIKit/UIView/exchangeSubview(at:withSubviewAt:))

Exchanges the subviews at the specified indices.

[`func isDescendant(of: UIView) -> Bool`](/documentation/UIKit/UIView/isDescendant(of:))

Returns a Boolean value indicating whether the receiver is a subview of a given view or identical to that view.

### Observing view-related changes

[`func didAddSubview(UIView)`](/documentation/UIKit/UIView/didAddSubview(_:))

Tells the view that a subview was added.

[`func willRemoveSubview(UIView)`](/documentation/UIKit/UIView/willRemoveSubview(_:))

Tells the view that a subview is about to be removed.

[`func willMove(toSuperview: UIView?)`](/documentation/UIKit/UIView/willMove(toSuperview:))

Tells the view that its superview is about to change to the specified superview.

[`func didMoveToSuperview()`](/documentation/UIKit/UIView/didMoveToSuperview())

Tells the view that its superview changed.

[`func willMove(toWindow: UIWindow?)`](/documentation/UIKit/UIView/willMove(toWindow:))

Tells the view that its window object is about to change.

[`func didMoveToWindow()`](/documentation/UIKit/UIView/didMoveToWindow())

Tells the view that its window object changed.

### Observing trait changes

[`protocol UITraitChangeObservable`](/documentation/UIKit/UITraitChangeObservable-67e94)

A type that calls your code in reaction to changes in the trait environment.

[`@protocol UITraitChangeObservable`](/documentation/UIKit/UITraitChangeObservable-7qoet)

A type that calls your code in reaction to changes in the trait environment.

### Requesting trait updates

[`func updateTraitsIfNeeded()`](/documentation/UIKit/UIView/updateTraitsIfNeeded())

Forces an immediate trait update for this view (and its view controller, if applicable) and any subviews,
including any view controllers or views in its subtree. Any trait change callbacks are sent synchronously.

### Overriding trait values

[`var traitOverrides: UITraitOverrides`](/documentation/UIKit/UIView/traitOverrides-fd9z)

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

A mutable container of traits you use to set trait changes for an object and its descendants.

[`@property (nonatomic, readonly) id<UITraitOverrides> traitOverrides;`](/documentation/UIKit/UIView/traitOverrides-2tqxk)

[`@protocol UITraitOverrides <UIMutableTraits>`](/documentation/UIKit/UITraitOverrides-c.protocol)

A mutable container of traits you use to set trait changes for an object and its descendants.

### Configuring content margins

[Positioning content within layout margins](/documentation/UIKit/positioning-content-within-layout-margins)

Position views so that they aren’t crowded by other content.

[`var directionalLayoutMargins: NSDirectionalEdgeInsets`](/documentation/UIKit/UIView/directionalLayoutMargins)

The default spacing to use when laying out content in a view, taking into account the current language direction.

[`var layoutMargins: UIEdgeInsets`](/documentation/UIKit/UIView/layoutMargins)

The default spacing to use when laying out content in the view.

[`var preservesSuperviewLayoutMargins: Bool`](/documentation/UIKit/UIView/preservesSuperviewLayoutMargins)

A Boolean value indicating whether the current view also respects the margins of its superview.

[`func layoutMarginsDidChange()`](/documentation/UIKit/UIView/layoutMarginsDidChange())

Notifies the view that the layout margins changed.

### Getting the safe area

[Positioning content relative to the safe area](/documentation/UIKit/positioning-content-relative-to-the-safe-area)

Position views so that they aren’t obstructed by other content.

[`var safeAreaInsets: UIEdgeInsets`](/documentation/UIKit/UIView/safeAreaInsets)

The insets that you use to determine the safe area for this view.

[`var safeAreaLayoutGuide: UILayoutGuide`](/documentation/UIKit/UIView/safeAreaLayoutGuide)

The layout guide representing the portion of your view that is unobscured by bars and other content.

[`func safeAreaInsetsDidChange()`](/documentation/UIKit/UIView/safeAreaInsetsDidChange())

Called when the safe area of the view changes.

[`var insetsLayoutMarginsFromSafeArea: Bool`](/documentation/UIKit/UIView/insetsLayoutMarginsFromSafeArea)

A Boolean value indicating whether the view’s layout margins are updated automatically to reflect the safe area.

### Managing the view’s constraints

Adjust the size and position of the view using Auto Layout constraints.

[`var constraints: [NSLayoutConstraint]`](/documentation/UIKit/UIView/constraints)

The constraints held by the view.

[`func addConstraint(NSLayoutConstraint)`](/documentation/UIKit/UIView/addConstraint(_:))

Adds a constraint on the layout of the receiving view or its subviews.

[`func addConstraints([NSLayoutConstraint])`](/documentation/UIKit/UIView/addConstraints(_:))

Adds multiple constraints on the layout of the receiving view or its subviews.

[`func removeConstraint(NSLayoutConstraint)`](/documentation/UIKit/UIView/removeConstraint(_:))

Removes the specified constraint from the view.

[`func removeConstraints([NSLayoutConstraint])`](/documentation/UIKit/UIView/removeConstraints(_:))

Removes the specified constraints from the view.

### Creating constraints using layout anchors

Attach Auto Layout constraints to one of the view’s anchors.

[`var bottomAnchor: NSLayoutYAxisAnchor`](/documentation/UIKit/UIView/bottomAnchor)

A layout anchor representing the bottom edge of the view’s frame.

[`var centerXAnchor: NSLayoutXAxisAnchor`](/documentation/UIKit/UIView/centerXAnchor)

A layout anchor representing the horizontal center of the view’s frame.

[`var centerYAnchor: NSLayoutYAxisAnchor`](/documentation/UIKit/UIView/centerYAnchor)

A layout anchor representing the vertical center of the view’s frame.

[`var firstBaselineAnchor: NSLayoutYAxisAnchor`](/documentation/UIKit/UIView/firstBaselineAnchor)

A layout anchor representing the baseline for the topmost line of text in the view.

[`var heightAnchor: NSLayoutDimension`](/documentation/UIKit/UIView/heightAnchor)

A layout anchor representing the height of the view’s frame.

[`var lastBaselineAnchor: NSLayoutYAxisAnchor`](/documentation/UIKit/UIView/lastBaselineAnchor)

A layout anchor representing the baseline for the bottommost line of text in the view.

[`var leadingAnchor: NSLayoutXAxisAnchor`](/documentation/UIKit/UIView/leadingAnchor)

A layout anchor representing the leading edge of the view’s frame.

[`var leftAnchor: NSLayoutXAxisAnchor`](/documentation/UIKit/UIView/leftAnchor)

A layout anchor representing the left edge of the view’s frame.

[`var rightAnchor: NSLayoutXAxisAnchor`](/documentation/UIKit/UIView/rightAnchor)

A layout anchor representing the right edge of the view’s frame.

[`var topAnchor: NSLayoutYAxisAnchor`](/documentation/UIKit/UIView/topAnchor)

A layout anchor representing the top edge of the view’s frame.

[`var trailingAnchor: NSLayoutXAxisAnchor`](/documentation/UIKit/UIView/trailingAnchor)

A layout anchor representing the trailing edge of the view’s frame.

[`var widthAnchor: NSLayoutDimension`](/documentation/UIKit/UIView/widthAnchor)

A layout anchor representing the width of the view’s frame.

### Working with layout guides

[`func addLayoutGuide(UILayoutGuide)`](/documentation/UIKit/UIView/addLayoutGuide(_:))

Adds the specified layout guide to the view.

[`var layoutGuides: [UILayoutGuide]`](/documentation/UIKit/UIView/layoutGuides)

The array of layout guide objects owned by this view.

[`var layoutMarginsGuide: UILayoutGuide`](/documentation/UIKit/UIView/layoutMarginsGuide)

A layout guide representing the view’s margins.

[`var readableContentGuide: UILayoutGuide`](/documentation/UIKit/UIView/readableContentGuide)

A layout guide representing an area with a readable width within the view.

[`func removeLayoutGuide(UILayoutGuide)`](/documentation/UIKit/UIView/removeLayoutGuide(_:))

Removes the specified layout guide from the view.

### Measuring in Auto Layout

[`func systemLayoutSizeFitting(CGSize) -> CGSize`](/documentation/UIKit/UIView/systemLayoutSizeFitting(_:))

Returns the optimal size of the view based on its current constraints.

[`func systemLayoutSizeFitting(CGSize, withHorizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize`](/documentation/UIKit/UIView/systemLayoutSizeFitting(_:withHorizontalFittingPriority:verticalFittingPriority:))

Returns the optimal size of the view based on its constraints and the specified fitting priorities.

[`var intrinsicContentSize: CGSize`](/documentation/UIKit/UIView/intrinsicContentSize)

The natural size for the receiving view, considering only properties of the view itself.

[`func invalidateIntrinsicContentSize()`](/documentation/UIKit/UIView/invalidateIntrinsicContentSize())

Invalidates the view’s intrinsic content size.

[`func contentCompressionResistancePriority(for: NSLayoutConstraint.Axis) -> UILayoutPriority`](/documentation/UIKit/UIView/contentCompressionResistancePriority(for:))

Returns the priority with which a view resists being made smaller than its intrinsic size.

[`func setContentCompressionResistancePriority(UILayoutPriority, for: NSLayoutConstraint.Axis)`](/documentation/UIKit/UIView/setContentCompressionResistancePriority(_:for:))

Sets the priority with which a view resists being made smaller than its intrinsic size.

[`func contentHuggingPriority(for: NSLayoutConstraint.Axis) -> UILayoutPriority`](/documentation/UIKit/UIView/contentHuggingPriority(for:))

Returns the priority with which a view resists being made larger than its intrinsic size.

[`func setContentHuggingPriority(UILayoutPriority, for: NSLayoutConstraint.Axis)`](/documentation/UIKit/UIView/setContentHuggingPriority(_:for:))

Sets the priority with which a view resists being made larger than its intrinsic size.

### Aligning views in Auto Layout

[`func alignmentRect(forFrame: CGRect) -> CGRect`](/documentation/UIKit/UIView/alignmentRect(forFrame:))

Returns the view’s alignment rectangle for a given frame.

[`func frame(forAlignmentRect: CGRect) -> CGRect`](/documentation/UIKit/UIView/frame(forAlignmentRect:))

Returns the view’s frame for a given alignment rectangle.

[`var alignmentRectInsets: UIEdgeInsets`](/documentation/UIKit/UIView/alignmentRectInsets)

The insets from the view’s frame that define its alignment rectangle.

[`var forFirstBaselineLayout: UIView`](/documentation/UIKit/UIView/forFirstBaselineLayout)

Returns a view used to satisfy first baseline constraints.

[`var forLastBaselineLayout: UIView`](/documentation/UIKit/UIView/forLastBaselineLayout)

Returns a view used to satisfy last baseline constraints.

### Triggering Auto Layout

[`func needsUpdateConstraints() -> Bool`](/documentation/UIKit/UIView/needsUpdateConstraints())

A Boolean value that determines whether the view’s constraints need updating.

[`func setNeedsUpdateConstraints()`](/documentation/UIKit/UIView/setNeedsUpdateConstraints())

Controls whether the view’s constraints need updating.

[`func updateConstraints()`](/documentation/UIKit/UIView/updateConstraints())

Updates constraints for the view.

[`func updateConstraintsIfNeeded()`](/documentation/UIKit/UIView/updateConstraintsIfNeeded())

Updates the constraints for the receiving view and its subviews.

### Debugging Auto Layout

[`func constraintsAffectingLayout(for: NSLayoutConstraint.Axis) -> [NSLayoutConstraint]`](/documentation/UIKit/UIView/constraintsAffectingLayout(for:))

Returns the constraints impacting the layout of the view for a given axis.

[`var hasAmbiguousLayout: Bool`](/documentation/UIKit/UIView/hasAmbiguousLayout)

A Boolean value that determines whether the constraints impacting the layout of the view incompletely specify the location of the view.

[`func exerciseAmbiguityInLayout()`](/documentation/UIKit/UIView/exerciseAmbiguityInLayout())

Randomly changes the frame of a view with an ambiguous layout between the different valid values.

### Configuring the resizing behavior

Define how a view adjusts its content when its bounds change.

[`var contentMode: UIView.ContentMode`](/documentation/UIKit/UIView/contentMode-swift.property)

A flag used to determine how a view lays out its content when its bounds change.

[`enum ContentMode`](/documentation/UIKit/UIView/ContentMode-swift.enum)

Options to specify how a view adjusts its content when its size changes.

[`func sizeThatFits(CGSize) -> CGSize`](/documentation/UIKit/UIView/sizeThatFits(_:))

Asks the view to calculate and return the size that best fits the specified size.

[`func sizeToFit()`](/documentation/UIKit/UIView/sizeToFit())

Resizes and moves the receiver view so it just encloses its subviews.

[`var autoresizesSubviews: Bool`](/documentation/UIKit/UIView/autoresizesSubviews)

A Boolean value that determines whether the receiver automatically resizes its subviews when its bounds change.

[`var autoresizingMask: UIView.AutoresizingMask`](/documentation/UIKit/UIView/autoresizingMask-swift.property)

An integer bit mask that determines how the receiver resizes itself when its superview’s bounds change.

### Laying out subviews

Lay out views manually if your app doesn’t use Auto Layout.

[`func layoutSubviews()`](/documentation/UIKit/UIView/layoutSubviews())

Lays out subviews.

[`func setNeedsLayout()`](/documentation/UIKit/UIView/setNeedsLayout())

Invalidates the current layout of the receiver and triggers a layout update during the next update cycle.

[`func layoutIfNeeded()`](/documentation/UIKit/UIView/layoutIfNeeded())

Lays out the subviews immediately, if layout updates are pending.

[`class var requiresConstraintBasedLayout: Bool`](/documentation/UIKit/UIView/requiresConstraintBasedLayout)

A Boolean value that indicates whether the receiver depends on the constraint-based layout system.

[`var translatesAutoresizingMaskIntoConstraints: Bool`](/documentation/UIKit/UIView/translatesAutoresizingMaskIntoConstraints)

A Boolean value that determines whether the view’s autoresizing mask converts to Auto Layout constraints.

### Accessing insets and layout guides

[`struct LayoutRegion`](/documentation/UIKit/UIView/LayoutRegion)

[`static func bar(onEdge: NSDirectionalRectEdge, extent: CGFloat) -> UIView.LayoutRegion`](/documentation/UIKit/UIView/LayoutRegion/bar(onEdge:extent:)-2tj1g)

[`static func bar(onEdge: UIRectEdge, extent: CGFloat) -> UIView.LayoutRegion`](/documentation/UIKit/UIView/LayoutRegion/bar(onEdge:extent:)-8rmhq)

[`@interface UIViewLayoutRegion : NSObject`](/documentation/UIKit/UIViewLayoutRegion)

[`enum UIViewLayoutRegionAdaptivityAxis : NSUInteger;`](/documentation/UIKit/UIViewLayoutRegionAdaptivityAxis)

[`func directionalEdgeInsets(for: UIView.LayoutRegion) -> NSDirectionalEdgeInsets`](/documentation/UIKit/UIView/directionalEdgeInsets(for:))

[`func edgeInsets(for: UIView.LayoutRegion) -> UIEdgeInsets`](/documentation/UIKit/UIView/edgeInsets(for:))

[`func layoutGuide(for: UIView.LayoutRegion) -> UILayoutGuide`](/documentation/UIKit/UIView/layoutGuide(for:))

### Inspecting reserved regions

[`struct ReservedRegion`](/documentation/UIKit/UIView/ReservedRegion)

A region within a view’s coordinate space that another entity occupies.

[`@interface UIViewReservedRegion : NSObject`](/documentation/UIKit/UIViewReservedRegion)

A region within a view’s coordinate space that another entity occupies.

[`func reservedRegions(kind: UIView.ReservedRegion.Kind, options: UIView.ReservedRegion.QueryOptions) -> [UIView.ReservedRegion]`](/documentation/UIKit/UIView/reservedRegions(kind:options:))

Returns the reserved regions of a given kind and options.

[`- (NSArray<UIViewReservedRegion *> *) reservedRegionsOfKind:(UIViewReservedRegionKind *) kind;`](/documentation/UIKit/UIView/reservedRegionsOfKind:)

Returns the reserved regions of a given kind.

[`- (NSArray<UIViewReservedRegion *> *) reservedRegionsOfKind:(UIViewReservedRegionKind *) kind options:(UIViewReservedRegionQueryOptions) options;`](/documentation/UIKit/UIView/reservedRegionsOfKind:options:)

Returns the reserved regions of a given kind and options.

### Adjusting the user interface

[`var overrideUserInterfaceStyle: UIUserInterfaceStyle`](/documentation/UIKit/UIView/overrideUserInterfaceStyle)

The user interface style adopted by the view and all of its subviews.

[`var semanticContentAttribute: UISemanticContentAttribute`](/documentation/UIKit/UIView/semanticContentAttribute)

A semantic description of the view’s contents, used to determine whether the view should be flipped when switching between left-to-right and right-to-left layouts.

[`var effectiveUserInterfaceLayoutDirection: UIUserInterfaceLayoutDirection`](/documentation/UIKit/UIView/effectiveUserInterfaceLayoutDirection)

The user interface layout direction appropriate for arranging the immediate content of the view.

[`class func userInterfaceLayoutDirection(for: UISemanticContentAttribute) -> UIUserInterfaceLayoutDirection`](/documentation/UIKit/UIView/userInterfaceLayoutDirection(for:))

Returns the user interface direction for the given semantic content attribute.

[`class func userInterfaceLayoutDirection(for: UISemanticContentAttribute, relativeTo: UIUserInterfaceLayoutDirection) -> UIUserInterfaceLayoutDirection`](/documentation/UIKit/UIView/userInterfaceLayoutDirection(for:relativeTo:))

Returns the layout direction implied by the specified semantic content attribute, relative to the specified layout direction.

### Constraining views to the keyboard

[`var keyboardLayoutGuide: UIKeyboardLayoutGuide`](/documentation/UIKit/UIView/keyboardLayoutGuide)

A layout guide that tracks the keyboard’s position in your app’s layout.

### Adding and removing interactions

[`func addInteraction(any UIInteraction)`](/documentation/UIKit/UIView/addInteraction(_:))

Adds an interaction to the view.

[`func removeInteraction(any UIInteraction)`](/documentation/UIKit/UIView/removeInteraction(_:))

Removes an interaction from the view.

[`var interactions: [any UIInteraction]`](/documentation/UIKit/UIView/interactions)

The array of interactions for the view.

[`protocol UIInteraction`](/documentation/UIKit/UIInteraction)

The protocol that an interaction implements to access the view that owns it.

### Drawing and updating the view

[`func draw(CGRect)`](/documentation/UIKit/UIView/draw(_:))

Draws the view’s image within the passed-in rectangle.

[`func setNeedsDisplay()`](/documentation/UIKit/UIView/setNeedsDisplay())

Marks the receiver’s entire bounds rectangle as needing to be redrawn.

[`func setNeedsDisplay(CGRect)`](/documentation/UIKit/UIView/setNeedsDisplay(_:))

Marks the specified rectangle of the receiver as needing to be redrawn.

[`var contentScaleFactor: CGFloat`](/documentation/UIKit/UIView/contentScaleFactor)

The scale factor applied to the view.

[`func tintColorDidChange()`](/documentation/UIKit/UIView/tintColorDidChange())

Called by the system when the tint color property changes.

### Updating the view when property values change

[`struct Invalidating`](/documentation/UIKit/UIView/Invalidating)

A property wrapper that notifies the system that a property value change has invalidated an aspect of the containing view.

[`protocol UIViewInvalidating`](/documentation/UIKit/UIViewInvalidating)

Implements a type of invalidation that can occur on a view that requires an update.

### Formatting printed view content

[`func viewPrintFormatter() -> UIViewPrintFormatter`](/documentation/UIKit/UIView/viewPrintFormatter())

Returns a print formatter for the receiving view.

[`func draw(CGRect, for: UIViewPrintFormatter)`](/documentation/UIKit/UIView/draw(_:for:))

Implemented to draw the view’s content for printing.

### Managing gesture recognizers

[`func addGestureRecognizer(UIGestureRecognizer)`](/documentation/UIKit/UIView/addGestureRecognizer(_:))

Attaches a gesture recognizer to the view.

[`func removeGestureRecognizer(UIGestureRecognizer)`](/documentation/UIKit/UIView/removeGestureRecognizer(_:))

Detaches a gesture recognizer from the receiving view.

[`var gestureRecognizers: [UIGestureRecognizer]?`](/documentation/UIKit/UIView/gestureRecognizers)

The gesture-recognizer objects currently attached to the view.

[`func gestureRecognizerShouldBegin(UIGestureRecognizer) -> Bool`](/documentation/UIKit/UIView/gestureRecognizerShouldBegin(_:))

Asks the view if the gesture recognizer should continue tracking touch events.

### Working with focus

[`var canBecomeFocused: Bool`](/documentation/UIKit/UIView/canBecomeFocused)

A Boolean value that indicates whether the view is currently capable of being focused.

[`class var inheritedAnimationDuration: TimeInterval`](/documentation/UIKit/UIView/inheritedAnimationDuration)

Returns the inherited duration of the current animation.

[`var isFocused: Bool`](/documentation/UIKit/UIView/isFocused)

A Boolean value that indicates whether the item is currently focused.

[`var focusGroupIdentifier: String?`](/documentation/UIKit/UIView/focusGroupIdentifier)

The identifier of the focus group that this view belongs to.

[`var focusEffect: UIFocusEffect?`](/documentation/UIKit/UIView/focusEffect)

The visual effect to apply when the view becomes focused.

[`var focusGroupPriority: UIFocusGroupPriority`](/documentation/UIKit/UIView/focusGroupPriority)

The importance of the item within a focus group, used by the focus system to determine the group’s primary item.

### Using motion effects

[`func addMotionEffect(UIMotionEffect)`](/documentation/UIKit/UIView/addMotionEffect(_:))

Begins applying a motion effect to the view.

[`var motionEffects: [UIMotionEffect]`](/documentation/UIKit/UIView/motionEffects)

The array of motion effects for the view.

[`func removeMotionEffect(UIMotionEffect)`](/documentation/UIKit/UIView/removeMotionEffect(_:))

Stops applying a motion effect to the view.

### Managing the hover appearance

[`var hoverStyle: UIHoverStyle?`](/documentation/UIKit/UIView/hoverStyle)

The hover style for the view.

[`class UIHoverStyle`](/documentation/UIKit/UIHoverStyle)

The hover style to apply to a view, including an effect and a shape to use for displaying that effect.

[`class UIHoverEffectLayer`](/documentation/UIKit/UIHoverEffectLayer)

A layer type that can be used to apply a hover effect to its sublayers.

### Managing font-sizing preferences

[`var minimumContentSizeCategory: UIContentSizeCategory?`](/documentation/UIKit/UIView/minimumContentSizeCategory)

The minimum content size category for the view and its subviews.

[`var maximumContentSizeCategory: UIContentSizeCategory?`](/documentation/UIKit/UIView/maximumContentSizeCategory)

The maximum content size category for the view and its subviews.

[`var appliedContentSizeCategoryLimitsDescription: String`](/documentation/UIKit/UIView/appliedContentSizeCategoryLimitsDescription)

A string that lists each of the view’s superviews, its content size category, and whether that view has content size category limits.

### Preserving and restoring state

[`var restorationIdentifier: String?`](/documentation/UIKit/UIView/restorationIdentifier)

The identifier that determines whether the view supports state restoration.

[`func encodeRestorableState(with: NSCoder)`](/documentation/UIKit/UIView/encodeRestorableState(with:))

Encodes state-related information for the view.

[`func decodeRestorableState(with: NSCoder)`](/documentation/UIKit/UIView/decodeRestorableState(with:))

Decodes and restores state-related information for the view.

### Capturing a view snapshot

[`func snapshotView(afterScreenUpdates: Bool) -> UIView?`](/documentation/UIKit/UIView/snapshotView(afterScreenUpdates:))

Returns a snapshot view based on the contents of the current view.

[`func resizableSnapshotView(from: CGRect, afterScreenUpdates: Bool, withCapInsets: UIEdgeInsets) -> UIView?`](/documentation/UIKit/UIView/resizableSnapshotView(from:afterScreenUpdates:withCapInsets:))

Returns a snapshot view based on the specified contents of the current view, with stretchable insets.

[`func drawHierarchy(in: CGRect, afterScreenUpdates: Bool) -> Bool`](/documentation/UIKit/UIView/drawHierarchy(in:afterScreenUpdates:))

Renders a snapshot of the complete view hierarchy as visible onscreen into the current context.

### Identifying the view at runtime

[`var tag: Int`](/documentation/UIKit/UIView/tag)

An integer that you can use to identify view objects in your application.

[`func viewWithTag(Int) -> UIView?`](/documentation/UIKit/UIView/viewWithTag(_:))

Returns the view whose tag matches the specified value.

### Converting between view coordinate systems

[`func convert(CGPoint, to: UIView?) -> CGPoint`](/documentation/UIKit/UIView/convert(_:to:)-1xizt)

Converts a point from the receiver’s coordinate system to that of the specified view.

[`func convert(CGPoint, from: UIView?) -> CGPoint`](/documentation/UIKit/UIView/convert(_:from:)-8neo1)

Converts a point from the coordinate system of a given view to that of the receiver.

[`func convert(CGRect, to: UIView?) -> CGRect`](/documentation/UIKit/UIView/convert(_:to:)-2kf3d)

Converts a rectangle from the receiver’s coordinate system to that of another view.

[`func convert(CGRect, from: UIView?) -> CGRect`](/documentation/UIKit/UIView/convert(_:from:)-7irzk)

Converts a rectangle from the coordinate system of another view to that of the receiver.

### Hit-testing in a view

[`func hitTest(CGPoint, with: UIEvent?) -> UIView?`](/documentation/UIKit/UIView/hitTest(_:with:))

Returns the farthest descendant in the view hierarchy of the current view, including itself, that contains the specified point.

[`func point(inside: CGPoint, with: UIEvent?) -> Bool`](/documentation/UIKit/UIView/point(inside:with:))

Returns a Boolean value indicating whether the receiver contains the specified point.

### Ending a view-editing session

[`func endEditing(Bool) -> Bool`](/documentation/UIKit/UIView/endEditing(_:))

Causes the view (or one of its embedded text fields) to resign the first responder status.

### Modifying the accessibility behavior

[`var accessibilityIgnoresInvertColors: Bool`](/documentation/UIKit/UIView/accessibilityIgnoresInvertColors)

A Boolean value indicating whether the view ignores an accessibility request to invert its colors.

[`var largeContentImage: UIImage?`](/documentation/UIKit/UIView/largeContentImage)

An image that represents the view in the large content viewer.

[`var largeContentImageInsets: UIEdgeInsets`](/documentation/UIKit/UIView/largeContentImageInsets)

Insets to adjust the position of the view’s image so it appears centered in the large content viewer.

[`var largeContentTitle: String?`](/documentation/UIKit/UIView/largeContentTitle)

A string that describes the view in the large content viewer.

[`var scalesLargeContentImage: Bool`](/documentation/UIKit/UIView/scalesLargeContentImage)

A Boolean value that indicates whether the large content viewer scales the item’s image to a larger size.

[`var showsLargeContentViewer: Bool`](/documentation/UIKit/UIView/showsLargeContentViewer)

A Boolean value that indicates whether to show the view in the large content viewer.

### Animating views

[`static func animate(Animation, changes: () -> Void, completion: (() -> Void)?)`](/documentation/UIKit/UIView/animate(_:changes:completion:))

[`class func animate(springDuration: TimeInterval, bounce: CGFloat, initialSpringVelocity: CGFloat, delay: TimeInterval, options: UIView.AnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/animate(springDuration:bounce:initialSpringVelocity:delay:options:animations:completion:))

Animates changes to one or more views using a spring animation with the specified duration, bounce, initial velocity, delay, options, and completion handler.

[`+ (void) animateWithSpringDuration:(NSTimeInterval) duration bounce:(CGFloat) bounce initialSpringVelocity:(CGFloat) velocity delay:(NSTimeInterval) delay options:(UIViewAnimationOptions) options animations:(void (^)()) animations completion:(void (^)(BOOL finished)) completion;`](/documentation/UIKit/UIView/animateWithSpringDuration:bounce:initialSpringVelocity:delay:options:animations:completion:)

Animates changes to one or more views using a spring animation with the specified duration, bounce, initial velocity, delay, options, and completion handler.

[`class func animate(withDuration: TimeInterval, delay: TimeInterval, options: UIView.AnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/animate(withDuration:delay:options:animations:completion:))

Animate changes to one or more views using the specified duration, delay, options, and completion handler.

[`class func animate(withDuration: TimeInterval, animations: () -> Void, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/animate(withDuration:animations:completion:))

Animate changes to one or more views using the specified duration and completion handler.

[`class func animate(withDuration: TimeInterval, animations: () -> Void)`](/documentation/UIKit/UIView/animate(withDuration:animations:))

Animate changes to one or more views using the specified duration.

[`class func transition(with: UIView, duration: TimeInterval, options: UIView.AnimationOptions, animations: (() -> Void)?, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/transition(with:duration:options:animations:completion:))

Creates a transition animation for the specified container view.

[`class func transition(from: UIView, to: UIView, duration: TimeInterval, options: UIView.AnimationOptions, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/transition(from:to:duration:options:completion:))

Creates a transition animation between the specified views using the given parameters.

[`class func animateKeyframes(withDuration: TimeInterval, delay: TimeInterval, options: UIView.KeyframeAnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/animateKeyframes(withDuration:delay:options:animations:completion:))

Creates an animation block object that can be used to set up keyframe-based animations for the current view.

[`class func addKeyframe(withRelativeStartTime: Double, relativeDuration: Double, animations: () -> Void)`](/documentation/UIKit/UIView/addKeyframe(withRelativeStartTime:relativeDuration:animations:))

Specifies the timing and animation values for a single frame of a keyframe animation.

[`class func perform(UIView.SystemAnimation, on: [UIView], options: UIView.AnimationOptions, animations: (() -> Void)?, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/perform(_:on:options:animations:completion:))

Performs a specified system-provided animation on one or more views, along with optional parallel animations that you define.

[`class func animate(withDuration: TimeInterval, delay: TimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIView.AnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?)`](/documentation/UIKit/UIView/animate(withDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:))

Performs a view animation using a timing curve corresponding to the motion of a physical spring.

[`class func performWithoutAnimation(() -> Void)`](/documentation/UIKit/UIView/performWithoutAnimation(_:))

Disables a view transition animation.

[`class func modifyAnimations(withRepeatCount: CGFloat, autoreverses: Bool, animations: () -> Void)`](/documentation/UIKit/UIView/modifyAnimations(withRepeatCount:autoreverses:animations:))

Repeats the specified animations a specific number of times, optionally running the animation forward and backward.

### Sensor coordinate orientation

  <doc://com.apple.documentation/documentation/CoreLocation/CLBodyIdentifiable>

  <doc://com.apple.documentation/documentation/CoreMotion/CMBodyIdentifiable>

### Constants

[`enum AnimationCurve`](/documentation/UIKit/UIView/AnimationCurve)

Specifies the supported animation curves.

[`struct AnimationOptions`](/documentation/UIKit/UIView/AnimationOptions)

Options for animating views using block objects.

[`enum AnimationTransition`](/documentation/UIKit/UIView/AnimationTransition)

Animation transition options for use in an animation block object.

[`enum SystemAnimation`](/documentation/UIKit/UIView/SystemAnimation)

Option to remove the views from the hierarchy when animation is complete.

[`struct KeyframeAnimationOptions`](/documentation/UIKit/UIView/KeyframeAnimationOptions)

Options for configuring keyframe-based animations.

[`enum Axis`](/documentation/UIKit/NSLayoutConstraint/Axis)

Keys that specify a horizontal or vertical layout constraint between objects.

[`enum TintAdjustmentMode`](/documentation/UIKit/UIView/TintAdjustmentMode-swift.enum)

The tint adjustment mode for the view.

[`class let layoutFittingCompressedSize: CGSize`](/documentation/UIKit/UIView/layoutFittingCompressedSize)

The option to use the smallest possible size.

[`class let layoutFittingExpandedSize: CGSize`](/documentation/UIKit/UIView/layoutFittingExpandedSize)

The option to use the largest possible size.

[`class let noIntrinsicMetric: CGFloat`](/documentation/UIKit/UIView/noIntrinsicMetric)

The absence of an intrinsic metric for a given numeric view property.

[`struct AutoresizingMask`](/documentation/UIKit/UIView/AutoresizingMask-swift.struct)

Options for automatic view resizing.

[`enum UISemanticContentAttribute`](/documentation/UIKit/UISemanticContentAttribute)

A semantic description of the view’s contents, used to determine whether the view should be flipped when switching between left-to-right and right-to-left layouts.

### Deprecated

[Deprecated symbols](/documentation/UIKit/uiview-deprecated-symbols)

Symbols that views no longer support.

### Initializers

[`convenience init()`](/documentation/UIKit/UIView/init())

### Instance Properties

[`var appEntityUIElementProvider: ((UIView, AppEntityUIElementsContext) -> [AppEntityUIElement])?`](/documentation/UIKit/UIView/appEntityUIElementProvider)

A closure that provides app entity identifiers to make custom view content discoverable by Apple Intelligence and Siri when it appears
onscreen.

### Instance Methods

[`func setNeedsUpdateProperties()`](/documentation/UIKit/UIView/setNeedsUpdateProperties())

Call to manually request a properties update for the view.
Multiple requests may be coalesced into a single update alongside the next layout pass.

[`func updateProperties()`](/documentation/UIKit/UIView/updateProperties())

Configures the view’s content and styling properties before layout.

[`func updatePropertiesIfNeeded()`](/documentation/UIKit/UIView/updatePropertiesIfNeeded())

Forces an immediate properties update for this view (and its view controller, if applicable)
and any subviews, including any view controllers or views in its subtree.

### Enumerations

[`enum Invalidations`](/documentation/UIKit/UIView/Invalidations)

Changes that cause an aspect of a view to be invalid and require an update.

### Default Implementations

[AppEntityAnnotatable Implementations](/documentation/UIKit/UIView/AppEntityAnnotatable-Implementations)

## Relationships

### Conforms To

[`UIFocusEnvironment`](/documentation/UIKit/UIFocusEnvironment)

[`Escapable`](/documentation/Swift/Escapable)

[`UITraitEnvironment`](/documentation/UIKit/UITraitEnvironment)

[`CMBodyIdentifiable`](/documentation/CoreMotion/CMBodyIdentifiable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`UIPopoverPresentationControllerSourceItem`](/documentation/UIKit/UIPopoverPresentationControllerSourceItem)

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`UIAccessibilityIdentification`](/documentation/UIKit/UIAccessibilityIdentification)

[`UIAppearance`](/documentation/UIKit/UIAppearance)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`UICoordinateSpace`](/documentation/UIKit/UICoordinateSpace)

[`NSTouchBarProvider`](/documentation/AppKit/NSTouchBarProvider)

[`UIUserActivityRestoring`](/documentation/UIKit/UIUserActivityRestoring)

[`UIDynamicItem`](/documentation/UIKit/UIDynamicItem)

[`UITraitChangeObservable-67e94`](/documentation/UIKit/UITraitChangeObservable-67e94)

[`UIResponderStandardEditActions`](/documentation/UIKit/UIResponderStandardEditActions)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`UIPasteConfigurationSupporting`](/documentation/UIKit/UIPasteConfigurationSupporting)

[`CLBodyIdentifiable`](/documentation/CoreLocation/CLBodyIdentifiable)

[`UILargeContentViewerItem`](/documentation/UIKit/UILargeContentViewerItem)

[`CVarArg`](/documentation/Swift/CVarArg)

[`AppEntityAnnotatable`](/documentation/AppIntents/AppEntityAnnotatable)

[`UIAppearanceContainer`](/documentation/UIKit/UIAppearanceContainer)

[`CALayerDelegate`](/documentation/QuartzCore/CALayerDelegate)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`UIFocusItemContainer`](/documentation/UIKit/UIFocusItemContainer)

[`UIFocusItem`](/documentation/UIKit/UIFocusItem)

[`Equatable`](/documentation/Swift/Equatable)

[`UIActivityItemsConfigurationProviding`](/documentation/UIKit/UIActivityItemsConfigurationProviding)

### Inherited By

[`UIProgressView`](/documentation/UIKit/UIProgressView)

[`UIActionSheet`](/documentation/UIKit/UIActionSheet)

[`UINavigationBar`](/documentation/UIKit/UINavigationBar)

[`UISearchBar`](/documentation/UIKit/UISearchBar)

[`UIWindow`](/documentation/UIKit/UIWindow)

[`UIStackView`](/documentation/UIKit/UIStackView)

[`UIContentUnavailableView`](/documentation/UIKit/UIContentUnavailableView)

[`UITabBar`](/documentation/UIKit/UITabBar)

[`UICalendarView`](/documentation/UIKit/UICalendarView)

[`UICollectionReusableView`](/documentation/UIKit/UICollectionReusableView)

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

[`UIStandardTextCursorView`](/documentation/UIKit/UIStandardTextCursorView)

[`UILabel`](/documentation/UIKit/UILabel)

[`UIImageView`](/documentation/UIKit/UIImageView)

[`UIVisualEffectView`](/documentation/UIKit/UIVisualEffectView)

[`UIWebView`](/documentation/UIKit/UIWebView)

[`UIInputView`](/documentation/UIKit/UIInputView)

[`UIPopoverBackgroundView`](/documentation/UIKit/UIPopoverBackgroundView)

[`UIBackgroundExtensionView`](/documentation/UIKit/UIBackgroundExtensionView)

[`UIActivityIndicatorView`](/documentation/UIKit/UIActivityIndicatorView)

[`UITableViewCell`](/documentation/UIKit/UITableViewCell)

[`UIEventAttributionView`](/documentation/UIKit/UIEventAttributionView)

[`UIPickerView`](/documentation/UIKit/UIPickerView)

[`UIScrollView`](/documentation/UIKit/UIScrollView)

[`UIListContentView`](/documentation/UIKit/UIListContentView)

[`UIToolbar`](/documentation/UIKit/UIToolbar)

[`UITableViewHeaderFooterView`](/documentation/UIKit/UITableViewHeaderFooterView)

[`UIAlertView`](/documentation/UIKit/UIAlertView)

### Inherits From

[`UIResponder`](/documentation/UIKit/UIResponder)

---

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)