Junior — Middle
Can you list and explain the main functions of the UIWindow class in iOS?
sobes.tech AI
Answer from AI
The UIWindow class in iOS represents the application's window, which acts as a container for displaying all visual elements (UIView). Main functions and properties of UIWindow:
- rootViewController — the controller that is the root for the window, managing the main interface.
- makeKeyAndVisible() — makes the window key (receiving events) and visible on the screen.
- isKeyWindow — a boolean property indicating whether the window is the key window.
- screen — the screen on which the window is displayed (useful for working with multiple screens).
- windowLevel — the level of the window, determining its display order above other windows (e.g., for pop-up windows).
Example usage:
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = myViewController
window.makeKeyAndVisible()
Thus, UIWindow manages the display and interaction with the user interface at the window level.