123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- //
- // ZBShopCarListCell.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/27.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBShopCarListCell.h"
- @implementation ZBShopCarListCell
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.backgroundColor=[UIColor whiteColor];
-
-
- [self addSubview:self.goodImgV];
- [self addSubview:self.titleLabel];
- [self addSubview:self.priceLabel];
- [self addSubview:self.oldPriceL];
- [self addSubview:self.orderpersonL];
-
- [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(100);
- make.left.top.mas_equalTo(10);
- }];
-
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.goodImgV.mas_right).offset(9);
- make.right.mas_equalTo(-9);
- make.height.mas_equalTo(38);
- make.top.mas_equalTo(15);
- }];
-
- [self.oldPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.titleLabel.mas_left);
- make.height.mas_equalTo(16);
- make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9);
- }];
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.titleLabel.mas_left);
- make.height.mas_equalTo(22);
- make.top.mas_equalTo(self.oldPriceL.mas_bottom).offset(9);
- }];
-
- [self.orderpersonL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.top.mas_equalTo(self.priceLabel.mas_top);
- make.height.mas_equalTo(22);
- }];
-
- UIImageView *lineV =[[UIImageView alloc]init];
- lineV.backgroundColor=[UIColor lineColor];
- [self addSubview:lineV];
-
- [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(1);
- make.top.mas_equalTo(self.goodImgV.mas_bottom).offset(10);
- }];
- }
- return self;
- }
- -(void)setModel:(ZBGoodModel *)model
- {
- _model = model;
- [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]];
- NSString *textStr =[NSString stringWithFormat:@"¥%@",model.zk_final_price];
-
- //中划线
- NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
- NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
- // 赋值
- self.oldPriceL.attributedText = attribtStr;
-
-
- NSString *titles=[NSString stringWithFormat:@"直播价¥%@",model.discount_price];
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:titles];
- [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xADAAAD] range:NSMakeRange(0,3)];
- [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体字号和字体类别
- [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x393939] range:NSMakeRange(3,titles.length-3)];
-
- _priceLabel.attributedText = str;
-
- // self.titleLabel.text=model.name;
- NSString *newstr=[NSString stringWithFormat:@"%@",model.name];
- NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:newstr];
- NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle1 setLineSpacing:2];
- [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [newstr length])];
- [self.titleLabel setAttributedText:attributedString1];
- [self.titleLabel sizeToFit];
-
- NSString *title1 = [NSString stringWithFormat:@" %@人下单 ",model.order_count];
- NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:title1];
-
- [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,title1.length-5)]; //设置字体字号和字体类别
-
- _orderpersonL.backgroundColor=[UIColor YHColorWithHex:0xFF7D00];
- _orderpersonL.attributedText = str1;
- }
- -(UIImageView *)goodImgV
- {
- if (!_goodImgV) {
- _goodImgV=[[UIImageView alloc]init];
- _goodImgV.backgroundColor=[UIColor lineColor];
- _goodImgV.layer.cornerRadius=4;
- _goodImgV.layer.masksToBounds=YES;
-
- }
- return _goodImgV;
- }
- -(UILabel *)titleLabel
- {
- if (!_titleLabel) {
- _titleLabel=[[UILabel alloc]init];
- _titleLabel.numberOfLines=2;
- _titleLabel.font=[UIFont systemFontOfSize:15];
- _titleLabel.textColor=[UIColor YHColorWithHex:0x262626];
- _titleLabel.text=@"---------";
- _titleLabel.numberOfLines=2;
- }
- return _titleLabel;
- }
- -(UILabel *)oldPriceL
- {
- if (!_oldPriceL) {
- _oldPriceL=[[UILabel alloc]init];
- _oldPriceL.font=[UIFont systemFontOfSize:11];
- _oldPriceL.textColor=[UIColor YHColorWithHex:0xBBB9BB];
- // _oldPriceL.text=@"99.99";
- NSString *textStr =@"¥99.99";
-
- //中划线
- NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
- NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
- // 赋值
- _oldPriceL.attributedText = attribtStr;
-
- }
- return _oldPriceL;
- }
- -(UILabel *)priceLabel
- {
- if (!_priceLabel) {
- _priceLabel=[[UILabel alloc]init];
- _priceLabel.font=[UIFont systemFontOfSize:12];
- _priceLabel.textColor=[UIColor YHColorWithHex:0x393939];
-
- NSString *title=@"直播价¥-----";
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
- [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xADAAAD] range:NSMakeRange(0,3)];
- [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体字号和字体类别
- [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x393939] range:NSMakeRange(3,title.length-3)];
-
- _priceLabel.attributedText = str;
- }
- return _priceLabel;
- }
- -(UILabel *)orderpersonL
- {
- if (!_orderpersonL) {
- _orderpersonL=[[UILabel alloc]init];
- _orderpersonL.font=[UIFont systemFontOfSize:12];
- _orderpersonL.layer.cornerRadius=2;
- _orderpersonL.layer.masksToBounds=YES;
- _orderpersonL.textColor=[UIColor whiteColor];
- NSString *title = @" -人下单 ";
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
- // [str addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,title.length-3)];
- [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,title.length-5)]; //设置字体字号和字体类别
- // [str addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(title.length-3,3)];
- _orderpersonL.backgroundColor=[UIColor YHColorWithHex:0xFF7D00];
- _orderpersonL.attributedText = str;
- }
- return _orderpersonL;
- }
- @end
|