<欢迎大家加入iOS开发学习交流群:QQ529560119>
写API的目的在于作为一个字典的作用。简单,明了,温习,复习。
//1.定义一个CGFloat类型的UIWindowLevel,UIWindowLevel分为三种不同选择,定义了UIWindow不同层级的展示方式,UIWindow在现实的时候会根据三种不同选择进行不同的排序,即level高的将排在level比他低的层级前面。
typedefCGFloat UIWindowLevel;
//2.添加UIScreen屏幕属性
@property(nonatomic,retain)UIScreen *screenNS_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
//3. UIWindowLevel属性
@property(nonatomic)UIWindowLevel windowLevel; // default = 0.0
//4.keyWindow是指定的用来接收键盘以及非触摸类的消息,而且程序中每一个时候只能有一个window是keyWindow
@property(nonatomic,readonly,getter=isKeyWindow)BOOL keyWindow;
//5.设置当前window变成主window
- (void)becomeKeyWindow; // override point for subclass. Do not call directly
//6.放弃当前主window
- (void)resignKeyWindow; // override point for subclass. Do not call directly
//7.让当前window变成keyWindow
- (void)makeKeyWindow;
//8.让当前window变成keyWindow,并显示出来
- (void)makeKeyAndVisible; // convenience. most apps call this to show the main window and also make it key. otherwise use view hidden property
//9.设置UIViewController为根控制器
@property(nonatomic,retain)UIViewController *rootViewController NS_AVAILABLE_IOS(4_0); // default is nil
//10.当产生一个事件时,先传递给UIApplication,而UIAppliaction将这个事件传递UIWindow进行处理,然后由UIWindow将这个时间传递给特定的对象,即first responder,而UIWindow就是通过sendEvent寻找first responder,经过sendEvent分发到合适的对象,sendEvent就相当于时间的中转站。
- (void)sendEvent:(UIEvent *)event; // called by UIApplication to dispatch events to views inside the window
//11.将当前window一个坐标转化为相对于另外一个窗口的坐标
- (CGPoint)convertPoint:(CGPoint)point toWindow:(UIWindow *)window; // can be used to convert to another window
//12.将另一个窗口的一个坐标转化为当前窗口的坐标
- (CGPoint)convertPoint:(CGPoint)point fromWindow:(UIWindow *)window; // pass in nil to mean screen
//13.转化当前窗口一个矩形坐标相对于当前窗口的坐标.
- (CGRect)convertRect:(CGRect)rect toWindow:(UIWindow *)window;
//14.转化里面那个外窗口一个矩形坐标相对于当前窗口的坐标
- (CGRect)convertRect:(CGRect)rect fromWindow:(UIWindow *)window;
@end
//15.定义UIWindow展示优先级不同层次的选择 ,根据window显示级别优先的原则,级别高的灰显示在上面,级别低的在下面,我们程序正常显示的位于最底层
UIKIT_EXTERNconstUIWindowLevel UIWindowLevelNormal;//默认的window就是Normal级别,优先级值这个层次的值为0,通常我们程序的界面都是处于这个Normal级别的
UIKIT_EXTERNconst UIWindowLevel UIWindowLevelAlert;//屏幕的statusBar处于中等水平,优先级值为1000
UIKIT_EXTERNconstUIWindowLevel UIWindowLevelStatusBar;// alert级别的,通常是UIAlertView和UIAlertSheet这些用来中断正常流程,提醒用户等操作的。优先级值为2000.按照这样说来,alertView弹框出来下面也是一层UIWindow,只不过是优先级最高的alert级别,所以是keyWindow,当前只能交互alert,这就是为什么弹框出来其他界面都不可交互的原因
//16.接下来是window变化的四个通知
UIKIT_EXTERNNSString *const UIWindowDidBecomeVisibleNotification; //当window显示就会调用
UIKIT_EXTERNNSString *const UIWindowDidBecomeHiddenNotification; //window被隐藏之后调用,需要注意的是,当程序进入后台时,这两个通知不会被调用,即使应用转到后台,窗口不会显示,窗口应用下的上下文中仍然被认为是可见的
UIKIT_EXTERNNSString *const UIWindowDidBecomeKeyNotification; //window成为主窗口调用
UIKIT_EXTERNNSString *const UIWindowDidResignKeyNotification; //window撤销主窗口调用
//17. 监听键盘变化的通知
UIKIT_EXTERNNSString *const UIKeyboardWillShowNotification; //当键盘将要显示的时候调用
UIKIT_EXTERNNSString *const UIKeyboardDidShowNotification; //当键盘已经显示的时候调用
UIKIT_EXTERNNSString *const UIKeyboardWillHideNotification; //当键盘将要隐藏的时候调用
UIKIT_EXTERNNSString *const UIKeyboardDidHideNotification;//当键盘隐藏完毕的时候调用
//18.关于监听键盘通知的一些userInfo消息
UIKIT_EXTERNNSString *const UIKeyboardFrameBeginUserInfoKey NS_AVAILABLE_IOS(3_2); //动画前键盘的位置,包含CGRect的NSValue可以在通知方法中写得到位置 CGRect rect = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
UIKIT_EXTERNNSString *const UIKeyboardFrameEndUserInfoKey NS_AVAILABLE_IOS(3_2);//动画结束后键盘的位置 包含CGRect的NSValue
UIKIT_EXTERNNSString *const UIKeyboardAnimationDurationUserInfoKeyNS_AVAILABLE_IOS(3_0);//动画的持续时间,数值是NSNumber
UIKIT_EXTERNNSString *const UIKeyboardAnimationCurveUserInfoKey NS_AVAILABLE_IOS(3_0); //动画的曲线类型(UIViewAnimationCurve),数值是NSNumber
//19.监听键盘frame大小变化的通知
UIKIT_EXTERNNSString *const UIKeyboardWillChangeFrameNotification NS_AVAILABLE_IOS(5_0); //当键盘frame值将要改变的时候调用
UIKIT_EXTERNNSString *const UIKeyboardDidChangeFrameNotification NS_AVAILABLE_IOS(5_0); //当键盘frame值已经改变的时候调用
//下面为一些废弃很久的API,不多做解释
UIKIT_EXTERNNSString *const UIKeyboardCenterBeginUserInfoKey NS_DEPRECATED_IOS(2_0,3_2);
UIKIT_EXTERNNSString *const UIKeyboardCenterEndUserInfoKey NS_DEPRECATED_IOS(2_0,3_2);
UIKIT_EXTERNNSString *const UIKeyboardBoundsUserInfoKey NS_DEPRECATED_IOS(2_0,3_2);