UIView(QMUI_ViewController)

@interface UIView (QMUI_ViewController)

/**
 判断当前的 view 是否属于可视(可视的定义为已存在于 view 层级树里,或者在所处的 UIViewController 的 [viewWillAppear, viewWillDisappear) 生命周期之间)
 */
@property(nonatomic, assign, readonly) BOOL qmui_visible;

/**
 当前的 view 是否是某个 UIViewController.view
 */
@property(nonatomic, assign) BOOL qmui_isControllerRootView;

/**
 获取当前 view 所在的 UIViewController,会递归查找 superview,因此注意使用场景不要有过于频繁的调用
 */
@property(nullable, nonatomic, weak, readonly) __kindof UIViewController *qmui_viewController;
@end

Undocumented

  • 判断当前的 view 是否属于可视(可视的定义为已存在于 view 层级树里,或者在所处的 UIViewController 的 [viewWillAppear, viewWillDisappear) 生命周期之间)

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL qmui_visible;

    Swift

    var qmui_visible: Bool { get }
  • 当前的 view 是否是某个 UIViewController.view

    Declaration

    Objective-C

    @property (nonatomic) BOOL qmui_isControllerRootView;

    Swift

    var qmui_isControllerRootView: Bool { get set }
  • 获取当前 view 所在的 UIViewController,会递归查找 superview,因此注意使用场景不要有过于频繁的调用

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly, nullable) __kindof UIViewController *qmui_viewController;

    Swift

    weak var qmui_viewController: UIViewController? { get }