// // YMAuthenticationCenterViewController.m // MSYOUPAI // // Created by YoMi on 2024/3/2. // Copyright © 2024 MS. All rights reserved. // #import "YMAuthenticationCenterViewController.h" #import "YMAuthenticationCenterViewModel.h" #import "YMAuthenticationCenterView.h" #import "YMGoddessCertifiedProtocolViewController.h" #import "YMCustomCameraViewController.h" @interface YMAuthenticationCenterViewController () /// 认证中心VM @property (nonatomic, strong) YMAuthenticationCenterViewModel *viewModel; /// 容器滚动视图 @property (nonatomic, strong) UIScrollView *contentScrollView; /// 容器视图 @property (nonatomic, strong) UIView *contentView; /// 认证中心视图 @property (nonatomic, strong) YMAuthenticationCenterView *authenticationCenterView; @end @implementation YMAuthenticationCenterViewController @dynamic viewModel; - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self deletUnwantedVC]; } - (void)ym_setupViews{ [self.view addSubview:self.contentScrollView]; [self.contentScrollView addSubview:self.contentView]; [self.contentView addSubview:self.authenticationCenterView]; [self.view setNeedsUpdateConstraints]; [self.view updateConstraintsIfNeeded]; } - (void)updateViewConstraints{ [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view).offset(kYMNavHeight); make.left.equalTo(self.view); make.right.equalTo(self.view); make.bottom.equalTo(self.view); }]; [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.contentScrollView); make.width.equalTo(self.contentScrollView.mas_width); }]; [self.authenticationCenterView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); make.bottom.equalTo(self.contentView); }]; [super updateViewConstraints]; } - (void)ym_bindViewModel{ [self.authenticationCenterView ym_bindViewModel:self.viewModel]; } #pragma mark - 删除不需要的视图控制器 - (void)deletUnwantedVC{ for (UIViewController *vc in self.navigationController.viewControllers) { if ([vc isKindOfClass:[YMGoddessCertifiedProtocolViewController class]] || [vc isKindOfClass:[YMCustomCameraViewController class]]) { [vc removeFromParentViewController]; } } } - (UIScrollView *)contentScrollView{ if (!_contentScrollView) { _contentScrollView = [[UIScrollView alloc]init]; _contentScrollView.alwaysBounceVertical = YES; _contentScrollView.showsVerticalScrollIndicator = NO; _contentScrollView.showsHorizontalScrollIndicator = NO; _contentScrollView.backgroundColor = UIColor.clearColor; _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; } return _contentScrollView; } - (UIView *)contentView{ if (!_contentView) { _contentView = [[UIView alloc]init]; } return _contentView; } - (YMAuthenticationCenterView *)authenticationCenterView{ if (!_authenticationCenterView) { _authenticationCenterView = [[YMAuthenticationCenterView alloc]init]; } return _authenticationCenterView; } @end