<!--
{
  "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/UIWindow",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIWindow"
  },
  "title" : "UIWindow"
}
-->

# UIWindow

The backdrop for your app’s user interface and the object that dispatches events to your views.

```
@MainActor class UIWindow
```

## Overview

Windows work with your view controllers to handle events and to perform many other tasks that are fundamental to your app’s operation. UIKit handles most window-related interactions, working with other objects as needed to implement many app behaviors.

You use windows only when you need to do the following:

- Provide a main window to display your app’s content.
- Create additional windows (as needed) to display additional content.

Normally, Xcode provides your app’s main window. New iOS projects use storyboards to define the app’s views. Storyboards require the presence of a [`window`](/documentation/UIKit/UIApplicationDelegate/window) property on the app delegate object, which the Xcode templates automatically provide. If your app doesn’t use storyboards, you must create this window yourself.

Most apps need only one window, which displays the app’s content on the device’s main screen. Although you can create additional windows on the device’s main screen, extra windows are commonly used to display content on an external screen, as described in [Presenting content on a connected display](/documentation/UIKit/presenting-content-on-a-connected-display).

You also use [`UIWindow`](/documentation/UIKit/UIWindow) objects for a handful of other tasks:

- Setting the z-axis level of your window, which affects the visibility of the window relative to other windows.
- Showing windows and making them the target of keyboard events.
- Converting coordinate values to and from the window’s coordinate system.
- Changing the root view controller of a window.
- Changing the screen on which the window is displayed.

Windows don’t have any visual appearance of their own. Instead, a window hosts one or more views, which are managed by the window’s root view controller. You configure the root view controller in your storyboards, adding whatever views are appropriate for your interface.

You should rarely need to subclass [`UIWindow`](/documentation/UIKit/UIWindow). The kinds of behaviors you might implement in a window can usually be implemented in a higher-level view controller more easily. One of the few times you might want to subclass is to override the [`becomeKey()`](/documentation/UIKit/UIWindow/becomeKey()) or [`resignKey()`](/documentation/UIKit/UIWindow/resignKey()) methods to implement custom behaviors when a window’s key status changes. For information about how to display a window on a specific screen, see [`UIScreen`](/documentation/UIKit/UIScreen).

### Understand keyboard interactions

Whereas touch events are delivered to the window where they occurred, events that don’t have a relevant coordinate value are delivered to the *key window*. Only one window at a time can be the key window, and you can use a window’s [`isKeyWindow`](/documentation/UIKit/UIWindow/isKeyWindow) property to determine its status. Most of the time, your app’s main window is the key window, but UIKit may designate a different window as needed.

If you need to know which window is key, observe the [`didBecomeKeyNotification`](/documentation/UIKit/UIWindow/didBecomeKeyNotification) and [`didResignKeyNotification`](/documentation/UIKit/UIWindow/didResignKeyNotification) notifications. The system sends those notifications on the main actor in response to key window changes in your app. To force a window become key, or to force a window to resign the key status, call the appropriate methods of this class.

## Topics

### Creating a window

[`init(windowScene:)`](/documentation/UIKit/UIWindow/init(windowScene:))

Creates a window and associates it with the specified scene object.

### Configuring the window

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

The root view controller for the window.

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

The position of the window in the z-axis.

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

The positioning of windows relative to each other.

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

A Boolean value that indicates whether the window’s constraint-based content determines its size.

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

The screen to display the window on.

### Making windows key

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

A Boolean value that indicates whether the window is the key window.

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

A Boolean value that indicates whether the window can become the key window.

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

Shows the window and makes it the key window.

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

Makes the window the key window.

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

Tells the window that it’s the key window.

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

Tells the window that it’s no longer the key window.

### Getting related objects

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

The scene containing the window.

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

The display manager that handles requests for screen resolution, refresh rate, and HDR mode information.

### Converting coordinates

[`convert(_:to:)`](/documentation/UIKit/UIWindow/convert(_:to:)-687rw)

Converts a point from the current window’s coordinate system to the coordinate system of another window.

[`convert(_:from:)`](/documentation/UIKit/UIWindow/convert(_:from:)-1gbm1)

Converts a point from the coordinate system of a given window to the coordinate system of the current window.

[`convert(_:to:)`](/documentation/UIKit/UIWindow/convert(_:to:)-7k3l0)

Converts a rectangle from the current window’s coordinate system to the coordinate system of another window.

[`convert(_:from:)`](/documentation/UIKit/UIWindow/convert(_:from:)-10p2b)

Converts a rectangle from the coordinate system of another window to coordinate system of the current window.

### Sending events

[`sendEvent(_:)`](/documentation/UIKit/UIWindow/sendEvent(_:))

Dispatches the specified event to its views.

### Responding to window-related notifications

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

A notification that posts when a window becomes visible.

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

A notification that posts when a window becomes hidden.

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

A notification that posts whenever a window becomes the key window.

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

A notification that posts whenever a window resigns its status as main window.

### Responding to keyboard notifications

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

A notification that posts immediately prior to displaying the keyboard.

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

A notification that posts immediately after displaying the keyboard.

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

A notification that posts immediately prior to dismissing the keyboard.

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

A notification that posts immediately after dismissing the keyboard.

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

A notification that posts immediately prior to a change in the keyboard’s frame.

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

A notification that posts immediately after a change in the keyboard’s frame.

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

A user info key to retrieve the animation curve that the system uses to animate the keyboard onto or off the screen.

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

A user info key to retrieve the duration of the keyboard animation in seconds.

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

A user info key to retrieve a Boolean value that indicates whether the keyboard belongs to the current app.

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

A user info key to retrieve the keyboard’s frame at the beginning of its animation.

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

A user info key to retrieve the keyboard’s frame at the end of its animation.

### Working with layout guides

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

A layout guide for placing content of a particular aspect ratio.

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

The interface for a layout guide that supports a particular aspect ratio.

### Deprecated

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

A user info key to retrieve the center point of the keyboard before its animation begins.

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

A user info key to retrieve the center point of the keyboard after its animation completes.

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

A user info key to retrieve the bounds of the keyboard.



---

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)
