123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- //
- // YMHomePageBannerOnTVCell.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/15.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMHomePageBannerOnTVCell.h"
- #import "YMHomePageBannerOnTVCellViewModel.h"
- @interface YMHomePageBannerOnTVCell()
- /// ViewModel
- @property (nonatomic, strong) YMHomePageBannerOnTVCellViewModel *viewModel;
- /// 基础视图
- @property (nonatomic, strong) UIView *baseView;
- /// 赠送者头像视图
- @property (nonatomic, strong) UIImageView *giverAvatarView;
- /// 赠送提示标题标签
- @property (nonatomic, strong) UILabel *giverTipsTitleLb;
- /// 赠送提示详情标签
- @property (nonatomic, strong) UILabel *giverTipsDetailLb;
- /// 礼物图标
- @property (nonatomic, strong) UIImageView *giftIcon;
- @end
- @implementation YMHomePageBannerOnTVCell
- - (void)ym_setupViews{
-
- [self.contentView addSubview:self.baseView];
-
- [self.baseView addSubview:self.giverAvatarView];
- [self.baseView addSubview:self.giverTipsTitleLb];
- [self.baseView addSubview:self.giverTipsDetailLb];
- // [self.baseView addSubview:self.giftIcon];
-
- [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.giverAvatarView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.baseView.mas_centerY);
- make.left.equalTo(self.baseView).offset(adapt(15));
- make.width.height.mas_equalTo(adapt(45));
- }];
-
- [self.giverTipsTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.giverAvatarView.mas_top).offset(adapt(5));
- make.left.equalTo(self.giverAvatarView.mas_right).offset(adapt(10));
- }];
-
- [self.giverTipsDetailLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.giverAvatarView.mas_bottom).offset(adapt(-5));
- make.left.equalTo(self.giverAvatarView.mas_right).offset(adapt(10));
- }];
-
- // [self.giftIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.centerY.equalTo(self.giverTipsTitleLb.mas_centerY);
- // make.left.equalTo(self.giverTipsTitleLb.mas_right).offset(adapt(5));
- // }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMHomePageBannerOnTVCellViewModel*)viewModel{
- if (!viewModel) {
- return;
- }
- _viewModel = viewModel;
-
- [self.giverAvatarView sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.viewModel.onTvGiverAvatar]];
- self.giverTipsTitleLb.attributedText = self.viewModel.giverTips;
- // [self.giftIcon sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.viewModel.onTvGiftIcon]];
- }
- - (UIView *)baseView{
- if (!_baseView) {
- _baseView = [[UIView alloc]init];
- }
- return _baseView;
- }
- - (UIImageView *)giverAvatarView{
- if (!_giverAvatarView) {
- _giverAvatarView = [[UIImageView alloc]init];
- _giverAvatarView.contentMode = UIViewContentModeScaleAspectFill;
- _giverAvatarView.layer.cornerRadius = adapt(45)/2;
- _giverAvatarView.layer.borderWidth = 1;
- _giverAvatarView.layer.borderColor = HexColorFromRGB(0xFFFFFF).CGColor;
- _giverAvatarView.clipsToBounds = YES;
- }
- return _giverAvatarView;
- }
- - (UILabel *)giverTipsTitleLb{
- if (!_giverTipsTitleLb) {
- _giverTipsTitleLb = [[UILabel alloc]init];
- _giverTipsTitleLb.font = LCFont(11);
- _giverTipsTitleLb.textColor = HexColorFromRGB(0xFFFFFF);
- _giverTipsTitleLb.textAlignment = NSTextAlignmentLeft;
- _giverTipsTitleLb.text = @"***送给***,*个****";
- }
- return _giverTipsTitleLb;
- }
- - (UILabel *)giverTipsDetailLb{
- if (!_giverTipsDetailLb) {
- _giverTipsDetailLb = [[UILabel alloc]init];
- _giverTipsDetailLb.font = LCBoldFont(11);
- _giverTipsDetailLb.textColor = HexColorFromRGB(0xFDCFFF);
- _giverTipsDetailLb.textAlignment = NSTextAlignmentLeft;
- _giverTipsDetailLb.text = @"一起祝福他们吧👏🏻👏🏻👏🏻👏🏻";
- }
- return _giverTipsDetailLb;
- }
- - (UIImageView *)giftIcon{
- if (!_giftIcon) {
- _giftIcon = [[UIImageView alloc]init];
- }
- return _giftIcon;
- }
- @end
|