YMAboutUsInfoView.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // YMAboutUsInfoView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/21.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMAboutUsInfoView.h"
  9. #import "YMAboutUsViewModel.h"
  10. @interface YMAboutUsInfoView ()
  11. /// 关于我们VM
  12. @property (nonatomic, strong) YMAboutUsViewModel *viewModel;
  13. /// App图标视图
  14. @property (nonatomic, strong) UIImageView *appIconView;
  15. /// App名称标签
  16. @property (nonatomic, strong) UILabel *appNameLb;
  17. /// App版本标签
  18. @property (nonatomic, strong) UILabel *appVersionLb;
  19. @end
  20. @implementation YMAboutUsInfoView
  21. - (void)ym_setupViews{
  22. [self addSubview:self.appIconView];
  23. [self addSubview:self.appNameLb];
  24. [self addSubview:self.appVersionLb];
  25. [self setNeedsUpdateConstraints];
  26. [self updateConstraintsIfNeeded];
  27. }
  28. - (void)updateConstraints{
  29. [self.appIconView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.centerX.equalTo(self.mas_centerX);
  31. make.bottom.equalTo(self.mas_centerY).offset(adapt(-15));
  32. make.width.height.mas_equalTo(adapt(80));
  33. }];
  34. [self.appNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.centerX.equalTo(self.appIconView.mas_centerX);
  36. make.top.equalTo(self.appIconView.mas_bottom).offset(adapt(15));
  37. }];
  38. [self.appVersionLb mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.centerX.equalTo(self.appIconView.mas_centerX);
  40. make.top.equalTo(self.appNameLb.mas_bottom).offset(adapt(15));
  41. }];
  42. [super updateConstraints];
  43. }
  44. - (void)ym_bindViewModel:(YMAboutUsViewModel *)viewModel{
  45. if (!viewModel) {
  46. return;
  47. }
  48. _viewModel = viewModel;
  49. }
  50. - (UIImageView *)appIconView{
  51. if (!_appIconView) {
  52. _appIconView = [[UIImageView alloc]init];
  53. _appIconView.image = ImageByName(@"AppIcon");
  54. _appIconView.backgroundColor = UIColor.lightGrayColor;
  55. _appIconView.layer.cornerRadius = adapt(8);
  56. _appIconView.layer.masksToBounds = YES;
  57. }
  58. return _appIconView;
  59. }
  60. - (UILabel *)appNameLb{
  61. if (!_appNameLb) {
  62. _appNameLb = [[UILabel alloc]init];
  63. _appNameLb.font = LCBoldFont(16);
  64. _appNameLb.textColor = HexColorFromRGB(0x333333);
  65. _appNameLb.textAlignment = NSTextAlignmentCenter;
  66. _appNameLb.text = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
  67. }
  68. return _appNameLb;
  69. }
  70. - (UILabel *)appVersionLb{
  71. if (!_appVersionLb) {
  72. _appVersionLb = [[UILabel alloc]init];
  73. _appVersionLb.font = LCFont(11);
  74. _appVersionLb.textColor = HexColorFromRGB(0x7E848D);
  75. _appVersionLb.textAlignment = NSTextAlignmentCenter;
  76. _appVersionLb.text = stringFormat(@"版本:v%@",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]);
  77. }
  78. return _appVersionLb;
  79. }
  80. @end