123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // YMPersonalPageInfoCell.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/18.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMPersonalPageInfoCell.h"
- #import "YMPersonalPageInfoCellViewModel.h"
- @interface YMPersonalPageInfoCell()
- /// ViewModel
- @property (nonatomic, strong) YMPersonalPageInfoCellViewModel *viewModel;
- /// 基础视图
- @property (nonatomic, strong) UIView *baseView;
- /// 信息标题标签
- @property (nonatomic, strong) UILabel *infoTitleLb;
- /// 信息内容标签
- @property (nonatomic, strong) UILabel *infoContentLb;
- /// 信息复制图标
- @property (nonatomic, strong) UIImageView *infoCopyIcon;
- @end
- @implementation YMPersonalPageInfoCell
- - (void)ym_setupViews{
-
- [self.contentView addSubview:self.baseView];
- [self.baseView addSubview:self.infoTitleLb];
- [self.baseView addSubview:self.infoContentLb];
- [self.baseView addSubview:self.infoCopyIcon];
-
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints {
- [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView);
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- make.bottom.equalTo(self.contentView);
- }];
-
- [self.infoTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.baseView).offset(adapt(5));
- make.left.equalTo(self.baseView).offset(adapt(5));
- make.bottom.equalTo(self.baseView).offset(adapt(-5));
- }];
-
- [self.infoContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.baseView).offset(adapt(5));
- make.left.equalTo(self.infoTitleLb.mas_right).offset(adapt(5));
- make.bottom.equalTo(self.baseView).offset(adapt(-5));
- }];
-
- [self.infoCopyIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.baseView.mas_centerY);
- make.left.equalTo(self.infoContentLb.mas_right).offset(adapt(5));
- make.width.height.mas_equalTo(adapt(20));
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMPersonalPageInfoCellViewModel*)viewModel{
- if (!viewModel) {
- return;
- }
- _viewModel = viewModel;
-
- self.infoTitleLb.text = self.viewModel.infoTitle;
- self.infoContentLb.text = self.viewModel.infoContent;
- self.infoCopyIcon.hidden = self.viewModel.isHideCopy;
- }
- - (UIView *)baseView{
- if (!_baseView) {
- _baseView = [[UIView alloc]init];
- }
- return _baseView;
- }
- - (UILabel *)infoTitleLb{
- if (!_infoTitleLb) {
- _infoTitleLb = [[UILabel alloc]init];
- _infoTitleLb.font = LCFont(12);
- _infoTitleLb.textColor = HexColorFromRGB(0x737373);
- _infoTitleLb.textAlignment = NSTextAlignmentLeft;
- _infoTitleLb.text = @"****";
- /**
- *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
- */
- [_infoTitleLb setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
- /**
- *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
- **/
- [_infoTitleLb setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _infoTitleLb;
- }
- - (UILabel *)infoContentLb{
- if (!_infoContentLb) {
- _infoContentLb = [[UILabel alloc]init];
- _infoContentLb.font = LCBoldFont(13);
- _infoContentLb.textColor = HexColorFromRGB(0x333333);
- _infoContentLb.textAlignment = NSTextAlignmentLeft;
- _infoContentLb.text = @"****";
- /**
- *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
- */
- [_infoContentLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
- /**
- *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
- **/
- [_infoContentLb setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _infoContentLb;
- }
- - (UIImageView *)infoCopyIcon{
- if (!_infoCopyIcon) {
- _infoCopyIcon = [[UIImageView alloc]init];
- _infoCopyIcon.image = ImageByName(@"ym_personal_page_copy_icon");
- /**
- *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
- */
- [_infoCopyIcon setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
- /**
- *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
- **/
- [_infoCopyIcon setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _infoCopyIcon;
- }
- @end
|