YMChatNotificationSectionHeaderView.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // YMChatNotificationSectionHeaderView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/22.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMChatNotificationSectionHeaderView.h"
  9. #import "YMChatNotificationSectionViewModel.h"
  10. @interface YMChatNotificationSectionHeaderView ()
  11. /// 消息通知-分组VM
  12. @property (nonatomic, strong) YMChatNotificationSectionViewModel *viewModel;
  13. /// 基础视图
  14. @property (nonatomic, strong) UIView *baseView;
  15. /// 功能标签
  16. @property (nonatomic, strong) UILabel *functionsLb;
  17. @end
  18. @implementation YMChatNotificationSectionHeaderView
  19. - (void)ym_setupViews{
  20. self.contentView.backgroundColor = UIColor.clearColor;
  21. [self.contentView addSubview:self.baseView];
  22. [self.baseView addSubview:self.functionsLb];
  23. [self setNeedsUpdateConstraints];
  24. [self updateConstraintsIfNeeded];
  25. }
  26. - (void)updateConstraints{
  27. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.top.equalTo(self.contentView);
  29. make.left.equalTo(self.contentView);
  30. make.right.equalTo(self.contentView);
  31. make.bottom.equalTo(self.contentView);
  32. }];
  33. [self.functionsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.centerY.equalTo(self.baseView.mas_centerY);
  35. make.left.equalTo(self.baseView).offset(adapt(15));
  36. make.right.equalTo(self.baseView).offset(adapt(-15));
  37. }];
  38. [super updateConstraints];
  39. }
  40. - (void)ym_bindViewModel:(YMChatNotificationSectionViewModel *)viewModel{
  41. if (!viewModel) {
  42. return;
  43. }
  44. _viewModel = viewModel;
  45. self.functionsLb.text = self.viewModel.sectionHeader;
  46. }
  47. - (UIView *)baseView{
  48. if (!_baseView) {
  49. _baseView = [[UIView alloc]init];
  50. _baseView.backgroundColor = HexColorFromRGB(0xF6F6F6);
  51. }
  52. return _baseView;
  53. }
  54. - (UILabel *)functionsLb{
  55. if (!_functionsLb) {
  56. _functionsLb = [[UILabel alloc]init];
  57. _functionsLb.font = LCFont(11);
  58. _functionsLb.textColor = HexColorFromRGB(0x969698);
  59. _functionsLb.textAlignment = NSTextAlignmentLeft;
  60. _functionsLb.numberOfLines = 3;
  61. _functionsLb.text = @"******";
  62. }
  63. return _functionsLb;
  64. }
  65. @end