YMAdolescentModelTipsView.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // YMAdolescentModelTipsView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/22.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMAdolescentModelTipsView.h"
  9. #import "YMAdolescentModelViewModel.h"
  10. @interface YMAdolescentModelTipsView ()
  11. /// 青少年模式VM
  12. @property (nonatomic, strong) YMAdolescentModelViewModel *viewModel;
  13. /// 青少年模式提示图片视图
  14. @property (nonatomic, strong) UIImageView *adolescentModelImageView;
  15. /// 青少年模式状态标签
  16. @property (nonatomic, strong) UILabel *adolescentModelStatusLb;
  17. /// 青少年模式提示标签
  18. @property (nonatomic, strong) UILabel *adolescentModelTipsLb;
  19. @end
  20. @implementation YMAdolescentModelTipsView
  21. - (void)ym_setupViews{
  22. [self addSubview:self.adolescentModelImageView];
  23. [self addSubview:self.adolescentModelStatusLb];
  24. [self addSubview:self.adolescentModelTipsLb];
  25. [self setNeedsUpdateConstraints];
  26. [self updateConstraintsIfNeeded];
  27. }
  28. - (void)updateConstraints{
  29. [self.adolescentModelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.centerX.equalTo(self.mas_centerX);
  31. make.top.equalTo(self).offset(adapt(30));
  32. make.width.mas_equalTo(adapt(230));
  33. make.height.mas_equalTo(adapt(230));
  34. }];
  35. [self.adolescentModelStatusLb mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.equalTo(self.adolescentModelImageView.mas_bottom).offset(adapt(15));
  37. make.left.equalTo(self).offset(adapt(15));
  38. make.right.equalTo(self).offset(adapt(-15));
  39. }];
  40. [self.adolescentModelTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.equalTo(self.adolescentModelStatusLb.mas_bottom).offset(adapt(15));
  42. make.left.equalTo(self).offset(adapt(15));
  43. make.right.equalTo(self).offset(adapt(-15));
  44. make.bottom.equalTo(self).offset(adapt(-30)).priorityHigh();
  45. }];
  46. [super updateConstraints];
  47. }
  48. - (void)ym_bindViewModel:(YMAdolescentModelViewModel *)viewModel{
  49. if (!viewModel) {
  50. return;
  51. }
  52. _viewModel = viewModel;
  53. }
  54. - (UIImageView *)adolescentModelImageView{
  55. if (!_adolescentModelImageView) {
  56. _adolescentModelImageView = [[UIImageView alloc]init];
  57. _adolescentModelImageView.image = ImageByName(@"ym_common_adolescent_model_tips_two_icon");
  58. }
  59. return _adolescentModelImageView;
  60. }
  61. - (UILabel *)adolescentModelStatusLb{
  62. if (!_adolescentModelStatusLb) {
  63. _adolescentModelStatusLb = [[UILabel alloc]init];
  64. _adolescentModelStatusLb.font = LCFont(15);
  65. _adolescentModelStatusLb.textColor = HexColorFromRGB(0x333333);
  66. _adolescentModelStatusLb.textAlignment = NSTextAlignmentCenter;
  67. _adolescentModelStatusLb.text = @"未成年模式已关闭";
  68. }
  69. return _adolescentModelStatusLb;
  70. }
  71. - (UILabel *)adolescentModelTipsLb{
  72. if (!_adolescentModelTipsLb) {
  73. _adolescentModelTipsLb = [[UILabel alloc]init];
  74. _adolescentModelTipsLb.font = LCFont(12);
  75. _adolescentModelTipsLb.textColor = HexColorFromRGB(0x9c9c9c);
  76. _adolescentModelTipsLb.textAlignment = NSTextAlignmentCenter;
  77. _adolescentModelTipsLb.text = @"开启未成年模式,防止未成年使用";
  78. }
  79. return _adolescentModelTipsLb;
  80. }
  81. @end