dkahgld

ZBShopCarListCell.m 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // ZBShopCarListCell.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/3/27.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBShopCarListCell.h"
  9. @implementation ZBShopCarListCell
  10. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  11. {
  12. self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
  13. if (self) {
  14. self.backgroundColor=[UIColor whiteColor];
  15. [self addSubview:self.goodImgV];
  16. [self addSubview:self.titleLabel];
  17. [self addSubview:self.priceLabel];
  18. [self addSubview:self.oldPriceL];
  19. [self addSubview:self.orderpersonL];
  20. [self.goodImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.width.height.mas_equalTo(100);
  22. make.left.top.mas_equalTo(10);
  23. }];
  24. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.left.mas_equalTo(self.goodImgV.mas_right).offset(9);
  26. make.right.mas_equalTo(-9);
  27. make.height.mas_equalTo(38);
  28. make.top.mas_equalTo(15);
  29. }];
  30. [self.oldPriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.mas_equalTo(self.titleLabel.mas_left);
  32. make.height.mas_equalTo(16);
  33. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(9);
  34. }];
  35. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(self.titleLabel.mas_left);
  37. make.height.mas_equalTo(22);
  38. make.top.mas_equalTo(self.oldPriceL.mas_bottom).offset(9);
  39. }];
  40. [self.orderpersonL mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.right.mas_equalTo(-10);
  42. make.top.mas_equalTo(self.priceLabel.mas_top);
  43. make.height.mas_equalTo(22);
  44. }];
  45. UIImageView *lineV =[[UIImageView alloc]init];
  46. lineV.backgroundColor=[UIColor lineColor];
  47. [self addSubview:lineV];
  48. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.mas_equalTo(10);
  50. make.right.mas_equalTo(-10);
  51. make.height.mas_equalTo(1);
  52. make.top.mas_equalTo(self.goodImgV.mas_bottom).offset(10);
  53. }];
  54. }
  55. return self;
  56. }
  57. -(void)setModel:(ZBGoodModel *)model
  58. {
  59. _model = model;
  60. [self.goodImgV sd_setImageWithURL:[NSURL URLWithString:model.img]];
  61. NSString *textStr =[NSString stringWithFormat:@"¥%@",model.zk_final_price];
  62. //中划线
  63. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  64. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  65. // 赋值
  66. self.oldPriceL.attributedText = attribtStr;
  67. NSString *titles=[NSString stringWithFormat:@"直播价¥%@",model.discount_price];
  68. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:titles];
  69. [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xADAAAD] range:NSMakeRange(0,3)];
  70. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体字号和字体类别
  71. [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x393939] range:NSMakeRange(3,titles.length-3)];
  72. _priceLabel.attributedText = str;
  73. // self.titleLabel.text=model.name;
  74. NSString *newstr=[NSString stringWithFormat:@"%@",model.name];
  75. NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:newstr];
  76. NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
  77. [paragraphStyle1 setLineSpacing:2];
  78. [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [newstr length])];
  79. [self.titleLabel setAttributedText:attributedString1];
  80. [self.titleLabel sizeToFit];
  81. NSString *title1 = [NSString stringWithFormat:@" %@人下单 ",model.order_count];
  82. NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:title1];
  83. [str1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,title1.length-5)]; //设置字体字号和字体类别
  84. _orderpersonL.backgroundColor=[UIColor YHColorWithHex:0xFF7D00];
  85. _orderpersonL.attributedText = str1;
  86. }
  87. -(UIImageView *)goodImgV
  88. {
  89. if (!_goodImgV) {
  90. _goodImgV=[[UIImageView alloc]init];
  91. _goodImgV.backgroundColor=[UIColor lineColor];
  92. _goodImgV.layer.cornerRadius=4;
  93. _goodImgV.layer.masksToBounds=YES;
  94. }
  95. return _goodImgV;
  96. }
  97. -(UILabel *)titleLabel
  98. {
  99. if (!_titleLabel) {
  100. _titleLabel=[[UILabel alloc]init];
  101. _titleLabel.numberOfLines=2;
  102. _titleLabel.font=[UIFont systemFontOfSize:15];
  103. _titleLabel.textColor=[UIColor YHColorWithHex:0x262626];
  104. _titleLabel.text=@"---------";
  105. _titleLabel.numberOfLines=2;
  106. }
  107. return _titleLabel;
  108. }
  109. -(UILabel *)oldPriceL
  110. {
  111. if (!_oldPriceL) {
  112. _oldPriceL=[[UILabel alloc]init];
  113. _oldPriceL.font=[UIFont systemFontOfSize:11];
  114. _oldPriceL.textColor=[UIColor YHColorWithHex:0xBBB9BB];
  115. // _oldPriceL.text=@"99.99";
  116. NSString *textStr =@"¥99.99";
  117. //中划线
  118. NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
  119. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
  120. // 赋值
  121. _oldPriceL.attributedText = attribtStr;
  122. }
  123. return _oldPriceL;
  124. }
  125. -(UILabel *)priceLabel
  126. {
  127. if (!_priceLabel) {
  128. _priceLabel=[[UILabel alloc]init];
  129. _priceLabel.font=[UIFont systemFontOfSize:12];
  130. _priceLabel.textColor=[UIColor YHColorWithHex:0x393939];
  131. NSString *title=@"直播价¥-----";
  132. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  133. [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xADAAAD] range:NSMakeRange(0,3)];
  134. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0,3)]; //设置字体字号和字体类别
  135. [str addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x393939] range:NSMakeRange(3,title.length-3)];
  136. _priceLabel.attributedText = str;
  137. }
  138. return _priceLabel;
  139. }
  140. -(UILabel *)orderpersonL
  141. {
  142. if (!_orderpersonL) {
  143. _orderpersonL=[[UILabel alloc]init];
  144. _orderpersonL.font=[UIFont systemFontOfSize:12];
  145. _orderpersonL.layer.cornerRadius=2;
  146. _orderpersonL.layer.masksToBounds=YES;
  147. _orderpersonL.textColor=[UIColor whiteColor];
  148. NSString *title = @" -人下单 ";
  149. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  150. // [str addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0,title.length-3)];
  151. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,title.length-5)]; //设置字体字号和字体类别
  152. // [str addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(title.length-3,3)];
  153. _orderpersonL.backgroundColor=[UIColor YHColorWithHex:0xFF7D00];
  154. _orderpersonL.attributedText = str;
  155. }
  156. return _orderpersonL;
  157. }
  158. @end