iOS-UIKit框架學習—UIWindow

b10l07發表於2017-01-20

一個UIWindow物件提供了您的應用程式的使用者介面的背景和提供了重要的事件處理行為。Windows沒有自己的任何視覺外觀,但它們對於應用程式檢視的呈現至關重要。螢幕上顯示的每個檢視都由一個視窗包圍,每個視窗獨立於應用程式中的其他視窗。應用程式接收的事件最初會傳送到相應的視窗物件,然後將這些事件轉發到相應的檢視。Windows與您的檢視控制器一起實現方向更改,並執行許多其他任務,這些任務是您應用程式操作的基礎。

// 相對窗的定位
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;

相關文章