美文网首页
UIWindow API个人翻译。(英语烂)

UIWindow API个人翻译。(英语烂)

作者: seven_words | 来源:发表于2016-03-19 21:11 被阅读0次

    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
    //发送事件
    //有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
    //键盘持续的时间
    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

    相关文章

      网友评论

          本文标题:UIWindow API个人翻译。(英语烂)

          本文链接:https://www.haomeiwen.com/subject/qsihlttx.html