---
title: rootViewController
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uiwindow/rootviewcontroller
---

# rootViewController

The root view controller for the window.

## Declaration

```swift
var rootViewController: UIViewController? { get set }
```

## Mentioned in

Managing content in your app’s windows

## Discussion

Discussion The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed. The default value of this property is nil.

## See Also

### Configuring the window

- [windowLevel](uikit/uiwindow/windowlevel.md)
- [UIWindow.Level](uikit/uiwindow/level.md)
- [canResizeToFitContent](uikit/uiwindow/canresizetofitcontent.md)
- [screen](uikit/uiwindow/screen.md)
