No Description

FKHotSaleCell.m 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // FKHotSaleCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 2017/6/10.
  6. // Copyright © 2017年 FirstLink. All rights reserved.
  7. //
  8. #import "FKHotSaleCell.h"
  9. @interface FKHotSaleCell ()
  10. @property (nonatomic, strong) UIView *horizonLine;
  11. @property (nonatomic, strong) UIButton *buyButton;
  12. @property (nonatomic, strong) UIView *bottomLine;
  13. @end
  14. @implementation FKHotSaleCell
  15. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  16. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  17. if (self) {
  18. self.selectionStyle = UITableViewCellSelectionStyleNone;
  19. [self setupViews];
  20. }
  21. return self;
  22. }
  23. #pragma mark - Method
  24. - (void)setupViews {
  25. [self.contentView addSubview:self.proImgView];
  26. [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.centerY.equalTo(self.contentView);
  28. make.left.equalTo(self.contentView).offset(12);
  29. make.size.mas_equalTo(CGSizeMake(112, 112));
  30. }];
  31. [self.contentView addSubview:self.proTitleLabel];
  32. [self.proTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.centerY.equalTo(self.proImgView.mas_top).offset(24);
  34. make.left.equalTo(self.proImgView.mas_right).offset(10);
  35. make.right.equalTo(self.contentView).offset(-12);
  36. }];
  37. [self.contentView addSubview:self.priceLabel];
  38. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(self.proImgView.mas_centerY).offset(-4);
  40. make.left.equalTo(self.proTitleLabel);
  41. }];
  42. [self.contentView addSubview:self.referPriceLabel];
  43. [self.referPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.centerY.equalTo(self.priceLabel);
  45. make.left.equalTo(self.priceLabel.mas_right).offset(10);
  46. }];
  47. [self.referPriceLabel addSubview:self.horizonLine];
  48. [self.horizonLine mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.centerY.equalTo(self.priceLabel);
  50. make.left.right.equalTo(self.referPriceLabel);
  51. make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
  52. }];
  53. [self.contentView addSubview:self.buyButton];
  54. [self.buyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.top.equalTo(self.priceLabel.mas_bottom).offset(12);
  56. make.right.equalTo(self.contentView).offset(-14);
  57. make.size.mas_equalTo(CGSizeMake(90, 23));
  58. }];
  59. [self.contentView addSubview:self.supplierImageView];
  60. [self.supplierImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.equalTo(self.proTitleLabel);
  62. make.centerY.equalTo(self.buyButton);
  63. make.size.mas_equalTo(CGSizeMake(80, 17));
  64. }];
  65. [self.contentView addSubview:self.bottomLine];
  66. [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.bottom.right.equalTo(self.contentView);
  68. make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
  69. }];
  70. // order label
  71. [self.contentView addSubview:self.orderImgView];
  72. [self.orderImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(self.contentView);
  74. make.top.equalTo(self.proImgView);
  75. }];
  76. [self.orderImgView addSubview:self.orderLabel];
  77. [self.orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.equalTo(self.orderImgView).offset(4);
  79. make.centerY.equalTo(self.orderImgView);
  80. }];
  81. }
  82. #pragma mark - Property
  83. - (UIImageView *)proImgView {
  84. if (!_proImgView) {
  85. _proImgView = [UIImageView new];
  86. _proImgView.contentMode = UIViewContentModeScaleAspectFit;
  87. }
  88. return _proImgView;
  89. }
  90. - (UILabel *)proTitleLabel {
  91. if (!_proTitleLabel) {
  92. _proTitleLabel = [UILabel new];
  93. _proTitleLabel.font = [UIFont systemFontOfSize:14];
  94. _proTitleLabel.textColor = UIColorFromRGB(0x333333);
  95. _proTitleLabel.numberOfLines = 2;
  96. }
  97. return _proTitleLabel;
  98. }
  99. - (UILabel *)priceLabel {
  100. if (!_priceLabel) {
  101. _priceLabel = [UILabel new];
  102. _priceLabel.font = [UIFont boldSystemFontOfSize:14];
  103. _priceLabel.textColor = UIColorFromRGB(0xff5656);
  104. }
  105. return _priceLabel;
  106. }
  107. - (UILabel *)referPriceLabel {
  108. if (!_referPriceLabel) {
  109. _referPriceLabel = [UILabel new];
  110. _referPriceLabel.font = [UIFont systemFontOfSize:12];
  111. _referPriceLabel.textColor = UIColorFromRGB(0x999999);
  112. }
  113. return _referPriceLabel;
  114. }
  115. - (UIView *)horizonLine {
  116. if (!_horizonLine) {
  117. _horizonLine = [UIView new];
  118. _horizonLine.backgroundColor = UIColorFromRGB(0x999999);
  119. }
  120. return _horizonLine;
  121. }
  122. - (UIButton *)buyButton {
  123. if (!_buyButton) {
  124. _buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  125. _buyButton.layer.cornerRadius = 12;
  126. [_buyButton.titleLabel setFont:[UIFont systemFontOfSize:12]];
  127. [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  128. _buyButton.userInteractionEnabled = NO;
  129. _buyButton.backgroundColor = UIColorFromRGB(0xff5656);
  130. [_buyButton setTitle:@"立即抢购" forState:UIControlStateNormal];
  131. }
  132. return _buyButton;
  133. }
  134. - (UIImageView *)supplierImageView {
  135. if (!_supplierImageView) {
  136. _supplierImageView = [[UIImageView alloc] init];
  137. _supplierImageView.contentMode = UIViewContentModeScaleAspectFit;
  138. }
  139. return _supplierImageView;
  140. }
  141. - (UIView *)bottomLine {
  142. if (!_bottomLine) {
  143. _bottomLine = [UIView new];
  144. _bottomLine.backgroundColor = UIColorFromRGB(0xf4f4f4);
  145. }
  146. return _bottomLine;
  147. }
  148. - (UIImageView *)orderImgView {
  149. if (!_orderImgView) {
  150. _orderImgView = [UIImageView new];
  151. _orderImgView.contentMode = UIViewContentModeScaleAspectFit;
  152. _orderImgView.image = [UIImage imageNamed:@"HotSaleOrderImgBg"];
  153. }
  154. return _orderImgView;
  155. }
  156. - (UILabel *)orderLabel {
  157. if (!_orderLabel) {
  158. _orderLabel = [UILabel new];
  159. _orderLabel.font = [UIFont boldSystemFontOfSize:13];
  160. _orderLabel.textColor = UIColorFromRGB(0xffffff);
  161. }
  162. return _orderLabel;
  163. }
  164. @end