123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- //
- // ZBHotSaleListCell.m
- // ZBProject
- //
- // Created by 学丽 on 2019/4/19.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBHotSaleListCell.h"
- @implementation ZBHotSaleListCell
- -(instancetype)initWithFrame:(CGRect)frame
- {
- self=[super initWithFrame:frame];
- if (self) {
- self.layer.cornerRadius=6;
- self.layer.masksToBounds=YES;
- self.backgroundColor=[UIColor whiteColor];
-
- [self addSubview:self.goodImgV];
- [self addSubview:self.titleLabel];
- [self addSubview:self.shopImg];
- [self addSubview:self.shopLabel];
- [self addSubview:self.priceLabel];
- [self addSubview:self.saleImgV];
- [self.saleImgV addSubview:self.salesCountL];
-
- [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(110);
- make.top.left.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.top.mas_equalTo(self.goodImgV.mas_top).offset(5);
- make.height.mas_equalTo(22);
- }];
-
- [self.shopImg mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.height.mas_equalTo(14);
- make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
- make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
- }];
-
- [self.shopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.shopImg.mas_right).offset(5);
- make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9);
- make.height.mas_equalTo(16);
- make.right.mas_equalTo(-10);
- }];
-
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.shopLabel.mas_bottom).offset(7);
- make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
- make.height.mas_equalTo(22);
- }];
- [self.saleImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.priceLabel.mas_bottom).offset(9);
- make.left.mas_equalTo(self.goodImgV.mas_right).offset(10);
- make.height.mas_equalTo(18);
- make.width.mas_equalTo(100);
- }];
-
- [self.salesCountL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-5);
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(24);
- make.bottom.mas_equalTo(0);
- make.height.mas_equalTo(18);
- }];
-
-
- }
- return self;
- }
- -(void)setModel:(ZBGoodModel *)model
- {
- _model= model;
- [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]];
- self.titleLabel.text=model.title;
- if (model.shop_type.integerValue == 1) {
- self.shopImg.image =[UIImage imageNamed:@"tm_icon"];
- }else{
- self.shopImg.image =[UIImage imageNamed:@"taobao_icon"];
- }
- self.shopLabel.text=model.shop_title;
- self.salesCountL.text=[NSString stringWithFormat:@"月销%@",model.volume];
-
- NSString *timetitle= [NSString stringWithFormat:@"¥%@/利润%@",model.discount_price,model.commission_rate];
- NSString *prices =[NSString stringWithFormat:@"¥%@/",model.discount_price];
- NSMutableAttributedString *timestr = [[NSMutableAttributedString alloc] initWithString:timetitle];
- [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x333333] range:NSMakeRange(0,prices.length)];
- [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别
- [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF7D00] range:NSMakeRange(prices.length,timetitle.length-prices.length)];
- self.priceLabel.attributedText=timestr;
-
-
-
-
- }
- -(UIImageView *)saleImgV
- {
- if (!_saleImgV) {
- _saleImgV=[[UIImageView alloc]init];
- _saleImgV.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xDDC179] toColor:[UIColor YHColorWithHex:0xC19E43] withWidth:100];
- _saleImgV.layer.cornerRadius=9;
- _saleImgV.layer.masksToBounds=YES;
- }
- return _saleImgV;
- }
- -(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.font=[UIFont systemFontOfSize:15];
- _titleLabel.textColor=[UIColor YHColorWithHex:0x333333];
- _titleLabel.text=@"---------";
- }
- return _titleLabel;
- }
- -(UILabel *)priceLabel
- {
- if (!_priceLabel) {
- _priceLabel=[[UILabel alloc]init];
- _priceLabel.font=[UIFont systemFontOfSize:16];
- _priceLabel.textColor=[UIColor YHColorWithHex:0x393939];
- _priceLabel.text=@"¥---";
- }
- return _priceLabel;
- }
- -(UIImageView *)shopImg
- {
- if (!_shopImg) {
-
- _shopImg =[[UIImageView alloc]init];
- [_shopImg setImage:[UIImage imageNamed:@"tm_icon"]];
- _shopImg.layer.cornerRadius=3;
- _shopImg.layer.masksToBounds=YES;
-
- }
- return _shopImg;
- }
- -(UILabel *)shopLabel
- {
- if (!_shopLabel) {
- _shopLabel=[[UILabel alloc]init];
- _shopLabel.text=@"----";
- _shopLabel.textColor=[UIColor YHColorWithHex:0x8D8A8A];
- _shopLabel.font=[UIFont systemFontOfSize:11];
-
- }
- return _shopLabel;
- }
- -(UILabel *)salesCountL
- {
- if (!_salesCountL) {
- _salesCountL=[[UILabel alloc]init];
- _salesCountL.text=@"月销--";
-
- _salesCountL.textColor=[UIColor whiteColor];
- _salesCountL.font=[UIFont systemFontOfSize:10];
-
- }
- return _salesCountL;
- }
- @end
|