// // QXNobilityPriceView.m // QXLive // // Created by 启星 on 2025/11/8. // #import "QXNobilityPriceView.h" @interface QXNobilityPriceView() @property (nonatomic,strong)UIImageView *bgImageView; @property (nonatomic,strong)UILabel *titleLabel; @property (nonatomic,strong)UILabel *timeLabel; @property (nonatomic,strong)UILabel *priceLabel; @property (nonatomic,strong)UILabel *originalPriceLabel; @property (nonatomic,strong)UIImageView *currentNobilityImageView; @end @implementation QXNobilityPriceView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)initSubviews{ self.bgImageView = [[UIImageView alloc] init]; self.bgImageView.backgroundColor = RGB16(0xFAF9D7); [self.bgImageView addRoundedCornersWithRadius:8]; [self addSubview:self.bgImageView];; [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(16); make.right.mas_equalTo(-16); make.top.mas_equalTo(34); make.bottom.equalTo(self); }]; self.currentNobilityImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]]; [self addSubview:self.currentNobilityImageView]; [self.currentNobilityImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self); make.right.equalTo(self.bgImageView.mas_right).offset(-34); make.height.width.mas_equalTo(104); }]; self.titleLabel = [[UILabel alloc] init]; self.titleLabel.textColor = RGB16(0x333333); self.titleLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:34]; [self addSubview:self.titleLabel]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.bgImageView).offset(22); make.top.equalTo(self.bgImageView).offset(18); make.height.mas_equalTo(44); }]; self.timeLabel = [[UILabel alloc] init]; self.timeLabel.textColor = RGB16A(0x000000, 0.65); self.timeLabel.font = [UIFont systemFontOfSize:12]; [self addSubview:self.timeLabel]; [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.titleLabel); make.top.equalTo(self.titleLabel.mas_bottom); }]; self.originalPriceLabel = [[UILabel alloc] init]; self.originalPriceLabel.textColor = RGB16(0x999999); self.originalPriceLabel.font = [UIFont systemFontOfSize:14]; [self addSubview:self.originalPriceLabel]; [self.originalPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.height.mas_equalTo(20); make.bottom.equalTo(self.bgImageView.mas_bottom); }]; self.priceLabel = [[UILabel alloc] init]; self.priceLabel.textColor = RGB16(0xFF2727); self.priceLabel.font = [UIFont systemFontOfSize:34]; [self addSubview:self.priceLabel]; [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.height.mas_equalTo(32); make.bottom.equalTo(self.originalPriceLabel.mas_top); }]; } -(void)setModel:(QXNobilityGetPriceModel *)model{ _model = model; [self.currentNobilityImageView sd_setImageWithURL:[NSURL URLWithString:model.nobility_image]]; self.titleLabel.text = model.nobility_name; self.timeLabel.text = [NSString stringWithFormat:@"有效期:%@天",model.day]; NSString *price = [NSString stringWithFormat:@"¥%@",model.price]; NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:price]; [attr yy_setFont:[UIFont systemFontOfSize:18] range:NSMakeRange(0, 1)]; self.priceLabel.attributedText = attr; NSAttributedString *at = [[NSString stringWithFormat:@"¥%@",model.pay_price] deleteLineWithTextColor:RGB16(0x999999) lineColor:RGB16(0x999999)]; self.originalPriceLabel.attributedText = at; } @end