12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //
- // YMFeesSettingNotesCell.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/24.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMFeesSettingNotesView.h"
- #import "YMFeesSettingViewModel.h"
- @interface YMFeesSettingNotesView ()
- /// 收费设置VM
- @property (nonatomic, strong) YMFeesSettingViewModel *viewModel;
- /// 说明提示标签
- @property (nonatomic, strong) YYLabel *notesTipsLb;
- @end
- @implementation YMFeesSettingNotesView
- - (void)ym_setupViews{
- [self addSubview:self.notesTipsLb];
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
-
- [self.notesTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(10));
- make.left.equalTo(self).offset(adapt(15));
- make.right.equalTo(self).offset(adapt(-15));
- make.bottom.equalTo(self).offset(adapt(-10));
- }];
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMFeesSettingViewModel *)viewModel{
-
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- @weakify(self)
- [[[[RACObserve(self.viewModel, notesTipsAttributed) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSAttributedString * notesTipsAttributed) {
- @strongify(self)
- self.notesTipsLb.attributedText = notesTipsAttributed;
-
- CGSize introSize = CGSizeMake(kFrameWidth - adapt(15)*2, CGFLOAT_MAX);
- YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:introSize text:viewModel.notesTipsAttributed];
- self.notesTipsLb.textLayout = layout;
- CGFloat notesTipsLbHeight = layout.textBoundingSize.height;
- [self.notesTipsLb mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(notesTipsLbHeight);
- }];
-
- if (self.notesViewHeightBlock) {
- self.notesViewHeightBlock(adapt(10) + notesTipsLbHeight + adapt(10));
- }
- }];
- }
- - (YYLabel *)notesTipsLb{
- if (!_notesTipsLb) {
- _notesTipsLb = [[YYLabel alloc]init];
- _notesTipsLb.font = LCFont(11);
- _notesTipsLb.textColor = HexColorFromRGB(0x9c9c9c);
- _notesTipsLb.textAlignment = NSTextAlignmentLeft;
- _notesTipsLb.numberOfLines = 0;
- }
- return _notesTipsLb;
- }
- @end
|