123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- //
- // KDPHistoryListCell.m
- // KuDianProject
- //
- // Created by 学丽 on 2019/7/9.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPHistoryListCell.h"
- @implementation KDPHistoryListCell
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self addSubview:self.goodImgV];
- [self addSubview:self.deleteButton];
- [self addSubview:self.priceLabel];
- [self addSubview:self.goodTitleL];
-
-
- [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(16);
- make.top.mas_equalTo(9);
- make.width.height.mas_equalTo(90);
-
- }];
-
- [self.goodTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(49);
- make.top.mas_equalTo(self.goodImgV.mas_top);
- make.left.mas_equalTo(self.goodImgV.mas_right).offset(13);
- make.right.mas_equalTo(-15);
- }];
-
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.goodTitleL.mas_left);
- make.top.mas_equalTo(self.goodTitleL.mas_bottom).offset(12);
- make.height.mas_equalTo(22);
- }];
-
- [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.width.mas_equalTo(22);
- make.top.mas_equalTo(self.priceLabel.mas_top);
- make.right.mas_equalTo(-15);
- }];
-
- UIView *lineV=[[UIView alloc]init];
- lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
- [self addSubview:lineV];
- [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- make.top.mas_equalTo(self.mas_bottom).offset(-1);
- make.height.mas_equalTo(1);
- }];
-
- }
-
- return self;
- }
- -(UILabel *)goodTitleL
- {
- if (!_goodTitleL) {
- _goodTitleL=[[UILabel alloc]init];
- _goodTitleL.text=@"---";
- _goodTitleL.numberOfLines=0;
- _goodTitleL.textColor=[UIColor colorWithHexString:fontColor];
- _goodTitleL.font=[UIFont systemFontOfSize:15];
-
- }
- return _goodTitleL;
- }
- -(UIButton *)deleteButton
- {
- if (!_deleteButton) {
- _deleteButton=[[UIButton alloc]init];
- [_deleteButton setImage:[UIImage imageNamed:@"delete_collection"] forState:UIControlStateNormal];
- _deleteButton.adjustsImageWhenHighlighted=NO;
- [_deleteButton addTarget:self action:@selector(deleteClickBtn) forControlEvents:UIControlEventTouchUpInside];
- }
- return _deleteButton;
- }
- -(UILabel *)priceLabel
- {
- if (!_priceLabel) {
- _priceLabel=[[UILabel alloc]init];
- _priceLabel.text=@"---";
- _priceLabel.font=[UIFont systemFontOfSize:16];
- NSString *prid=@"¥--.- /";
-
- NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ 利润--",prid]];
- [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:NSMakeRange(0, prid.length)];
- [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:NSMakeRange(prid.length,AttributedStr.length-prid.length)];
- [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(0, prid.length)];
- [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(prid.length,AttributedStr.length-prid.length)];
- _priceLabel.attributedText=AttributedStr;
- }
- return _priceLabel;
-
- }
- -(UIImageView *)goodImgV
- {
- if (!_goodImgV) {
- _goodImgV=[[UIImageView alloc]init];
- _goodImgV.backgroundColor=[UIColor colorWithHexString:LineColor];
- _goodImgV.layer.cornerRadius=4;
- _goodImgV.layer.masksToBounds=YES;
- }
- return _goodImgV;
- }
- -(void)setModel:(KDPGoodsModel *)model
- {
- _model = model;
- [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]];
- self.goodTitleL.attributedText=[KDPublicMethod sethanggaoWithStr:model.title linSpacing:5];
- 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 colorWithHexString:@"#333333"] range:NSMakeRange(0,prices.length)];
- [timestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(prices.length,2)]; //设置字体字号和字体类别
- [timestr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:ThemeColor] range:NSMakeRange(prices.length,timetitle.length-prices.length)];
-
- self.priceLabel.attributedText=timestr;
-
- }
- -(void)deleteClickBtn
- {
- if (self.deleteBlock) {
- self.deleteBlock(self.model);
- }
- }
- @end
|