YMAuthenticationCenterViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // YMAuthenticationCenterViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/2.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMAuthenticationCenterViewController.h"
  9. #import "YMAuthenticationCenterViewModel.h"
  10. #import "YMAuthenticationCenterView.h"
  11. #import "YMGoddessCertifiedProtocolViewController.h"
  12. #import "YMCustomCameraViewController.h"
  13. @interface YMAuthenticationCenterViewController ()
  14. /// 认证中心VM
  15. @property (nonatomic, strong) YMAuthenticationCenterViewModel *viewModel;
  16. /// 容器滚动视图
  17. @property (nonatomic, strong) UIScrollView *contentScrollView;
  18. /// 容器视图
  19. @property (nonatomic, strong) UIView *contentView;
  20. /// 认证中心视图
  21. @property (nonatomic, strong) YMAuthenticationCenterView *authenticationCenterView;
  22. @end
  23. @implementation YMAuthenticationCenterViewController
  24. @dynamic viewModel;
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. }
  28. - (void)viewDidAppear:(BOOL)animated{
  29. [super viewDidAppear:animated];
  30. [self deletUnwantedVC];
  31. }
  32. - (void)ym_setupViews{
  33. [self.view addSubview:self.contentScrollView];
  34. [self.contentScrollView addSubview:self.contentView];
  35. [self.contentView addSubview:self.authenticationCenterView];
  36. [self.view setNeedsUpdateConstraints];
  37. [self.view updateConstraintsIfNeeded];
  38. }
  39. - (void)updateViewConstraints{
  40. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.equalTo(self.view).offset(kYMNavHeight);
  42. make.left.equalTo(self.view);
  43. make.right.equalTo(self.view);
  44. make.bottom.equalTo(self.view);
  45. }];
  46. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.edges.equalTo(self.contentScrollView);
  48. make.width.equalTo(self.contentScrollView.mas_width);
  49. }];
  50. [self.authenticationCenterView mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.equalTo(self.contentView);
  52. make.left.equalTo(self.contentView);
  53. make.right.equalTo(self.contentView);
  54. make.bottom.equalTo(self.contentView);
  55. }];
  56. [super updateViewConstraints];
  57. }
  58. - (void)ym_bindViewModel{
  59. [self.authenticationCenterView ym_bindViewModel:self.viewModel];
  60. }
  61. #pragma mark - 删除不需要的视图控制器
  62. - (void)deletUnwantedVC{
  63. for (UIViewController *vc in self.navigationController.viewControllers) {
  64. if ([vc isKindOfClass:[YMGoddessCertifiedProtocolViewController class]] || [vc isKindOfClass:[YMCustomCameraViewController class]]) {
  65. [vc removeFromParentViewController];
  66. }
  67. }
  68. }
  69. - (UIScrollView *)contentScrollView{
  70. if (!_contentScrollView) {
  71. _contentScrollView = [[UIScrollView alloc]init];
  72. _contentScrollView.alwaysBounceVertical = YES;
  73. _contentScrollView.showsVerticalScrollIndicator = NO;
  74. _contentScrollView.showsHorizontalScrollIndicator = NO;
  75. _contentScrollView.backgroundColor = UIColor.clearColor;
  76. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  77. }
  78. return _contentScrollView;
  79. }
  80. - (UIView *)contentView{
  81. if (!_contentView) {
  82. _contentView = [[UIView alloc]init];
  83. }
  84. return _contentView;
  85. }
  86. - (YMAuthenticationCenterView *)authenticationCenterView{
  87. if (!_authenticationCenterView) {
  88. _authenticationCenterView = [[YMAuthenticationCenterView alloc]init];
  89. }
  90. return _authenticationCenterView;
  91. }
  92. @end