iOS UIKit框架学习—UIWindow

一个UIWindow对象提供了您的应用程序的用户界面的背景和提供了重要的事件处理行为。Windows没有自己的任何视觉外观,但它们对于应用程序视图的呈现至关重要。屏幕上显示的每个视图都由一个窗口包围,每个窗口独立于应用程序中的其他窗口。应用程序接收的事件最初会传送到相应的窗口对象,然后将这些事件转发到相应的视图。Windows与您的视图控制器一起实现方向更改,并执行许多其他任务,这些任务是您应用程序操作的基础。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// 相对窗的定位
typedef CGFloat UIWindowLevel;
@class UIEvent, UIScreen, NSUndoManager, UIViewController;
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIWindow : UIView
// 显示窗口的屏幕
@property(nonatomic,strong) UIScreen *screen NS_AVAILABLE_IOS(3_2);
// 该窗口在Z轴的位置。
@property(nonatomic) UIWindowLevel windowLevel; // default = 0.0
// 该窗口是不是应用的主视图
@property(nonatomic,readonly,getter=isKeyWindow) BOOL keyWindow;
// 通知已经变为主视图
- (void)becomeKeyWindow;
// 通知应经不是主视图
- (void)resignKeyWindow;
// 接收关键窗口
- (void)makeKeyWindow;
// 显示窗口并使其成为关键窗口
- (void)makeKeyAndVisible;
// 窗口的跟视图控制器
@property(nullable, nonatomic,strong) UIViewController *rootViewController NS_AVAILABLE_IOS(4_0); // default is nil
// 发送指定事件 UIApplication通过此方法来调度事件窗口
- (void)sendEvent:(UIEvent *)event;
// 转换一个点从接受对象的坐标系到指定窗口
- (CGPoint)convertPoint:(CGPoint)point toWindow:(nullable UIWindow *)window;
// 与上面相反,指定窗口坐标中的一个点转换为接收对象
- (CGPoint)convertPoint:(CGPoint)point fromWindow:(nullable UIWindow *)window;
// 将当前的矩形坐标空间转换到指定的矩形窗口空间
- (CGRect)convertRect:(CGRect)rect toWindow:(nullable UIWindow *)window;
// 将指定的矩形坐标空间转换到当前的矩形窗口空间
- (CGRect)convertRect:(CGRect)rect fromWindow:(nullable UIWindow *)window;
@end
UIKIT_EXTERN const UIWindowLevel UIWindowLevelNormal;
UIKIT_EXTERN const UIWindowLevel UIWindowLevelAlert;
UIKIT_EXTERN const UIWindowLevel UIWindowLevelStatusBar __TVOS_PROHIBITED;
UIKIT_EXTERN NSNotificationName const UIWindowDidBecomeVisibleNotification;
UIKIT_EXTERN NSNotificationName const UIWindowDidBecomeHiddenNotification;
UIKIT_EXTERN NSNotificationName const UIWindowDidBecomeKeyNotification;
UIKIT_EXTERN NSNotificationName const UIWindowDidResignKeyNotification;
UIKIT_EXTERN NSNotificationName const UIKeyboardWillShowNotification __TVOS_PROHIBITED;
UIKIT_EXTERN NSNotificationName const UIKeyboardDidShowNotification __TVOS_PROHIBITED;
UIKIT_EXTERN NSNotificationName const UIKeyboardWillHideNotification __TVOS_PROHIBITED;
UIKIT_EXTERN NSNotificationName const UIKeyboardDidHideNotification __TVOS_PROHIBITED;
UIKIT_EXTERN NSString *const UIKeyboardFrameBeginUserInfoKey NS_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED; // NSValue of CGRect
UIKIT_EXTERN NSString *const UIKeyboardFrameEndUserInfoKey NS_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED; // NSValue of CGRect
UIKIT_EXTERN NSString *const UIKeyboardAnimationDurationUserInfoKey NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // NSNumber of double
UIKIT_EXTERN NSString *const UIKeyboardAnimationCurveUserInfoKey NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED; // NSNumber of NSUInteger (UIViewAnimationCurve)
UIKIT_EXTERN NSString *const UIKeyboardIsLocalUserInfoKey NS_AVAILABLE_IOS(9_0) __TVOS_PROHIBITED; // NSNumber of BOOL
UIKIT_EXTERN NSNotificationName const UIKeyboardWillChangeFrameNotification NS_AVAILABLE_IOS(5_0) __TVOS_PROHIBITED;
UIKIT_EXTERN NSNotificationName const UIKeyboardDidChangeFrameNotification NS_AVAILABLE_IOS(5_0) __TVOS_PROHIBITED;
UIKIT_EXTERN NSString *const UIKeyboardCenterBeginUserInfoKey NS_DEPRECATED_IOS(2_0, 3_2) __TVOS_PROHIBITED;
UIKIT_EXTERN NSString *const UIKeyboardCenterEndUserInfoKey NS_DEPRECATED_IOS(2_0, 3_2) __TVOS_PROHIBITED;
UIKIT_EXTERN NSString *const UIKeyboardBoundsUserInfoKey NS_DEPRECATED_IOS(2_0, 3_2) __TVOS_PROHIBITED;