RQBaseViewController.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // RQBaseViewController.h
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/13.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "RQBaseViewModel.h"
  10. static inline UIEdgeInsets rq_safeAreaInset(UIView *view) {
  11. if (@available(iOS 11.0, *)) {
  12. return view.safeAreaInsets;
  13. }
  14. return UIEdgeInsetsZero;
  15. }
  16. @interface RQBaseViewController : QMUICommonViewController
  17. /// The `viewModel` parameter in `-initWithViewModel:` method.
  18. @property (nonatomic, readonly, strong) RQBaseViewModel *viewModel;
  19. /// 截图(Push/Pop Present/Dismiss 过度过程中的缩略图)
  20. @property (nonatomic, readwrite, strong) UIView *snapshot;
  21. /**
  22. 统一使用该方法初始化,子类中直接声明对于的'readonly' 的 'viewModel'属性,
  23. 并在@implementation内部加上关键词 '@dynamic viewModel;'
  24. @dynamic A相当于告诉编译器:“参数A的getter和setter方法并不在此处,
  25. 而在其他地方实现了或者生成了,当你程序运行的时候你就知道了,
  26. 所以别警告我了”这样程序在运行的时候,
  27. 对应参数的getter和setter方法就会在其他地方去寻找,比如父类。
  28. */
  29. /// Initialization method. This is the preferred way to create a new view.
  30. ///
  31. /// viewModel - corresponding view model
  32. ///
  33. /// Returns a new view.
  34. - (instancetype)initWithViewModel:(RQBaseViewModel *)viewModel;
  35. /// Binds the corresponding view model to the view.(绑定数据模型)
  36. - (void)bindViewModel;
  37. @end