UIWindow API
我果果的官方文檔
最近被逼得很鬧心茎活,要努力看果果官方文檔才不會太生氣昙沦。
我有上網查一些資料,如果引用了载荔,敬請見諒
//NS_ASSUME_NONNULL_BEGIN假設不為空的開始盾饮,我上網查了,說這個是oc的一個新特性懒熙,類似于swift的!和?丐谋。
NS_ ASSUME _ NONNULL_BEGIN
typedef CGFloat UIWindowLevel;
@class UIEvent, UIScreen, NSUndoManager, UIViewController;
//這個類至少得是ios2.0以上的版本才可以使用。并且繼承UIView煌珊。
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIWindow : UIView
//screen默認是一個線程安全的強引用号俐。并且至少在ios3.2以上才可以用。初始化的時候默認的是 UIScreen的 mainScreen定庵。并且改變這個screen是一個不劃算的事情吏饿。(官方建議你別動它)
@property(nonatomic,strong) UIScreen *screen NS_AVAILABLE_IOS(3_2); // default is [UIScreen mainScreen]. changing the screen may be an expensive operation and should not be done in performance-sensitive code
//UIWindowLevel是前面定義的一個float型的變量。默認0.0
@property(nonatomic) UIWindowLevel windowLevel; // default = 0.0
//不會解釋但是知道意思蔬浙,定義一個只讀的保證線程安全的bool值猪落,(大致覺得應該是,是否是主窗口的意思)
@property(nonatomic,readonly,getter=isKeyWindow) BOOL keyWindow;
//可以在子類重寫畴博,不能直接調用
//一個是成為主窗口笨忌,另外一個是將其設成不是主窗口
- (void)becomeKeyWindow; // override point for subclass. Do not call directly
- (void)resignKeyWindow; // override point for subclass. Do not call directly
//制作主窗口,和制作主窗口的并且可視的俱病。
- (void)makeKeyWindow;
- //方便官疲,大多數app調用它去展示其主窗口并且也可以制作其鍵。否則使用view否認的屬性
- (void)makeKeyAndVisible; // convenience. most apps call this to show the main window and also make it key. otherwise use view hidden property
//可以為空亮隙,線程安全途凫,強類型。(默認為空)
@property(nullable, nonatomic,strong) UIViewController *rootViewController
//可以在ios4.0以上使用
NS_AVAILABLE_IOS(4_0); // default is nil
//發(fā)送事件
//有UIApplication調用去調度事件在window里的view
- (void)sendEvent:(UIEvent *)event; // called by UIApplication to dispatch events to views inside the window
//四個坐標轉換溢吻。
- (CGPoint)convertPoint:(CGPoint)point toWindow:(nullable UIWindow *)window; // can be used to convert to another window
- //
- (CGPoint)convertPoint:(CGPoint)point fromWindow:(nullable UIWindow *)window; // pass in nil to mean screen
- (CGRect)convertRect:(CGRect)rect toWindow:(nullable UIWindow *)window;
- (CGRect)convertRect:(CGRect)rect fromWindow:(nullable UIWindow *)window;
@end
//UIWindowLevel總共有三種級別:
UIWindowLevleNormal,
UIWindowLevelAlert;
//其中normal級別最低维费,再而是statusBar,級別最高的是alertView,alertView一般用來中斷用戶事件。打印出他們的值分別是0.0000促王,1000和2000
UIWindowLevelStatusBar;
UIKIT_EXTERN const UIWindowLevel UIWindowLevelNormal;
UIKIT_EXTERN const UIWindowLevel UIWindowLevelAlert;
UIKIT_EXTERN const UIWindowLevel UIWindowLevelStatusBar __TVOS_PROHIBITED;
// 這四個通知對象中的object都代表當前已顯示(隱藏)犀盟,已變成keyWindow(非keyWindow)的window對象,其中的userInfo則是空的蝇狼。于是我們可以注冊這個四個消息阅畴,再打印信息來觀察keyWindow的變化以及window的顯示,隱藏的變動
UIKIT_EXTERN NSString *const UIWindowDidBecomeVisibleNotification; // nil
UIKIT_EXTERN NSString *const UIWindowDidBecomeHiddenNotification; // nil
UIKIT_EXTERN NSString *const UIWindowDidBecomeKeyNotification; // nil
UIKIT_EXTERN NSString *const UIWindowDidResignKeyNotification; // nil
//每一個通知包括一個空的對象和一個用戶信息字典包含鍵盤的開始和結束框架在屏幕坐標题翰。使用可變的UIView并且UIWindow可以轉換設備想要的坐標系恶阴,動畫的鍵值對僅僅可用will的通知诈胜。
// Each notification includes a nil object and a userInfo dictionary containing the
// begining and ending keyboard frame in screen coordinates. Use the various UIView and
// UIWindow convertRect facilities to get the frame in the desired coordinate system.
// Animation key/value pairs are only available for the "will" family of notification.
//鍵盤方面的通知
UIKIT_EXTERN NSString *const UIKeyboardWillShowNotification;
UIKIT_EXTERN NSString *const UIKeyboardDidShowNotification;
UIKIT_EXTERN NSString *const UIKeyboardWillHideNotification;
UIKIT_EXTERN NSString *const UIKeyboardDidHideNotification;
//鍵盤開始的坐標
UIKIT_EXTERN NSString *const UIKeyboardFrameBeginUserInfoKey NS_AVAILABLE_IOS(3_2); // NSValue of CGRect
//鍵盤結束的坐標
UIKIT_EXTERN NSString *const UIKeyboardFrameEndUserInfoKey NS_AVAILABLE_IOS(3_2); // NSValue of CGRect
//鍵盤持續(xù)的時間
UIKIT_EXTERN NSString *const UIKeyboardAnimationDurationUserInfoKey NS_AVAILABLE_IOS(3_0); // NSNumber of double
//鍵盤動畫效果
UIKIT_EXTERN NSString *const UIKeyboardAnimationCurveUserInfoKey NS_AVAILABLE_IOS(3_0); // NSNumber of NSUInteger (UIViewAnimationCurve)
//鍵盤本地信息
UIKIT_EXTERN NSString *const UIKeyboardIsLocalUserInfoKey NS_AVAILABLE_IOS(9_0); // NSNumber of BOOL
// Like the standard keyboard notifications above, these additional notifications include
// a nil object and begin/end frames of the keyboard in screen coordinates in the userInfo dictionary.
//像一個標準的鍵盤通知,這些除了通知以外還包括一個空的對象冯事,和在用戶的字典里的一個空的對象和鍵盤在屏幕坐標系里的開始和結束的框架
UIKIT_EXTERN NSString *const UIKeyboardWillChangeFrameNotification NS_AVAILABLE_IOS(5_0);
UIKIT_EXTERN NSString *const UIKeyboardDidChangeFrameNotification NS_AVAILABLE_IOS(5_0);
// These keys are superseded by UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey.
//這些是用來代替UIKeyboardFrameBeginUserInfoKey焦匈,UIKeyboardFrameEndUserInfoKey做UI知道的約束類型
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;
//假設不是空的結束
NS_ASSUME_NONNULL_END