《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRModuleCollectionCell.m 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // DRModuleCollectionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/4.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRModuleCollectionCell.h"
  9. @interface DRModuleCollectionCell()
  10. @property (nonatomic, strong) UIImageView *iconView;
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @property (nonatomic, strong) UILabel *priceLabel;
  13. @property (nonatomic, strong) UILabel *disPrice;
  14. @end
  15. @implementation DRModuleCollectionCell
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.layer.cornerRadius = 6;
  20. self.layer.masksToBounds = YES;
  21. [self initSubViews];
  22. }
  23. return self;
  24. }
  25. - (void)initSubViews {
  26. [self.contentView addSubview:self.iconView];
  27. [self.contentView addSubview:self.titleLabel];
  28. [self.contentView addSubview:self.priceLabel];
  29. [self.contentView addSubview:self.disPrice];
  30. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.left.right.mas_equalTo(0);
  32. make.height.mas_equalTo(self.iconView.mas_width);
  33. }];
  34. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.left.right.mas_equalTo(0);
  36. make.top.mas_equalTo(self.iconView.mas_bottom).mas_offset(Fitsize(10));
  37. }];
  38. [self.disPrice mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.left.mas_equalTo(0);
  40. make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(Fitsize(6));
  41. }];
  42. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(self.disPrice.mas_right).mas_offset(3);
  44. make.bottom.mas_equalTo(self.disPrice.mas_bottom).mas_offset(-1);
  45. }];
  46. }
  47. - (void)setModel:(DRChildGoodModel *)model {
  48. _model = model;
  49. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:Placehold_Img];
  50. self.titleLabel.text = model.title;
  51. self.disPrice.text = [NSString stringWithFormat:@"¥%.2f",[model.discount_price floatValue]];
  52. NSString *price=[NSString stringWithFormat:@"%.2f",[model.price floatValue]];
  53. NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:price];
  54. [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, price.length)];
  55. [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor YHColorWithHex:0x999999] range:NSMakeRange(0, price.length)];
  56. self.priceLabel.attributedText = attri;
  57. }
  58. #pragma mark --- layzer ---
  59. - (UIImageView *)iconView {
  60. if (!_iconView) {
  61. _iconView = [[UIImageView alloc] init];
  62. _iconView.backgroundColor = [UIColor yhGrayColor];
  63. _iconView.layer.cornerRadius = 5;
  64. _iconView.layer.masksToBounds = YES;
  65. }
  66. return _iconView;
  67. }
  68. - (UILabel *)titleLabel {
  69. if (!_titleLabel) {
  70. _titleLabel = [[UILabel alloc] init];
  71. _titleLabel.numberOfLines = 1;
  72. _titleLabel.textColor = [UIColor YHColorWithHex:0x333333];
  73. _titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
  74. }
  75. return _titleLabel;
  76. }
  77. - (UILabel *)priceLabel {
  78. if (!_priceLabel) {
  79. _priceLabel = [[UILabel alloc] init];
  80. _priceLabel.textColor = [UIColor YHColorWithHex:0x999999];
  81. _priceLabel.font = [UIFont systemFontOfSize:Fitsize(11)];
  82. }
  83. return _priceLabel;
  84. }
  85. - (UILabel *)disPrice {
  86. if (!_disPrice) {
  87. _disPrice = [[UILabel alloc] init];
  88. _disPrice.font = [UIFont systemFontOfSize:Fitsize(15)];
  89. _disPrice.textColor = [UIColor homeRedColor];
  90. }
  91. return _disPrice;
  92. }
  93. @end