Nenhuma Descrição

FKDetailGroupBuyView.m 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // FKDetailGroupBuyCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 15/10/8.
  6. // Copyright © 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKDetailGroupBuyView.h"
  9. @interface FKDetailGroupBuyView ()
  10. @property (nonatomic, strong) UILabel *groupPriceLabel;
  11. @property (nonatomic, strong) UILabel *groupTipLabel;
  12. @property (nonatomic, strong) UILabel *directPriceLabel;
  13. @property (nonatomic, strong) UILabel *directTipLabel;
  14. @end
  15. @implementation FKDetailGroupBuyView
  16. /*
  17. // Only override drawRect: if you perform custom drawing.
  18. // An empty implementation adversely affects performance during animation.
  19. - (void)drawRect:(CGRect)rect {
  20. // Drawing code
  21. }
  22. */
  23. #pragma mark - Function
  24. + (CGFloat)height {
  25. return 60;
  26. }
  27. - (void)configUIForTip {
  28. [self removeAllSubviews];
  29. self.textColor = UIColorFromRGB(0xffffff);
  30. self.backgroundColor = UIColorFromRGB(0xfcbf4a);
  31. self.textAlignment = NSTextAlignmentCenter;
  32. self.font = [UIFont systemFontOfSize:16];
  33. self.text = @"本次活动已结束,去看看其它商品";
  34. }
  35. - (void)configUIForBuy:(NSString *)normalPrice groupPrice:(NSString *)groupPrice {
  36. [self addAllSubviewsForBuy:normalPrice
  37. groupPrice:groupPrice];
  38. }
  39. #pragma mark - Method
  40. - (void)removeAllSubviews {
  41. [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  42. [obj removeFromSuperview];
  43. }];
  44. }
  45. - (void)addAllSubviewsForBuy:(NSString *)normalPrice groupPrice:(NSString *)groupPrice {
  46. [self removeAllSubviews];
  47. self.groupPriceLabel.text = groupPrice;
  48. self.directPriceLabel.text = normalPrice;
  49. WeakSelf(weakSelf);
  50. [self addSubview:self.groupBuyButton];
  51. [self.groupBuyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.right.top.bottom.equalTo(weakSelf);
  53. }];
  54. [self addSubview:self.directBuyButton];
  55. [self.directBuyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.left.top.bottom.equalTo(weakSelf);
  57. make.right.mas_equalTo(weakSelf.groupBuyButton.mas_left);
  58. make.width.mas_equalTo(weakSelf.groupBuyButton.mas_width);
  59. }];
  60. [self.groupBuyButton addSubview:self.groupTipLabel];
  61. [self.groupTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.right.equalTo(weakSelf.groupBuyButton);
  63. make.bottom.equalTo(weakSelf.groupBuyButton).offset(-11);
  64. make.height.mas_equalTo(18);
  65. }];
  66. [self.groupBuyButton addSubview:self.groupPriceLabel];
  67. [self.groupPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.right.equalTo(weakSelf.groupBuyButton);
  69. make.bottom.equalTo(weakSelf.groupTipLabel.mas_top);
  70. make.height.mas_equalTo(20);
  71. }];
  72. [self.directBuyButton addSubview:self.directTipLabel];
  73. [self.directTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.right.equalTo(weakSelf.directBuyButton);
  75. make.bottom.equalTo(weakSelf.directBuyButton).offset(-11);
  76. make.height.mas_equalTo(18);
  77. }];
  78. [self.directBuyButton addSubview:self.directPriceLabel];
  79. [self.directPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.right.equalTo(weakSelf.directBuyButton);
  81. make.bottom.equalTo(weakSelf.directTipLabel.mas_top);
  82. make.height.mas_equalTo(20);
  83. }];
  84. }
  85. #pragma mark - Property
  86. - (UIButton *)groupBuyButton {
  87. if (!_groupBuyButton) {
  88. _groupBuyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  89. _groupBuyButton.backgroundColor = UIColorFromRGB(0x00c8a9);
  90. }
  91. return _groupBuyButton;
  92. }
  93. - (UIButton *)directBuyButton {
  94. if (!_directBuyButton) {
  95. _directBuyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  96. _directBuyButton.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
  97. }
  98. return _directBuyButton;
  99. }
  100. - (UILabel *)groupTipLabel {
  101. if (!_groupTipLabel) {
  102. _groupTipLabel = [[UILabel alloc]init];
  103. _groupTipLabel.textColor = UIColorFromRGB(0xffffff);
  104. _groupTipLabel.textAlignment = NSTextAlignmentCenter;
  105. _groupTipLabel.font = [UIFont systemFontOfSize:14];
  106. _groupTipLabel.text = @"成为团长并开团";
  107. }
  108. return _groupTipLabel;
  109. }
  110. - (UILabel *)groupPriceLabel {
  111. if (!_groupPriceLabel) {
  112. _groupPriceLabel = [[UILabel alloc]init];
  113. _groupPriceLabel.textColor = UIColorFromRGB(0xffffff);
  114. _groupPriceLabel.textAlignment = NSTextAlignmentCenter;
  115. _groupPriceLabel.font = [UIFont systemFontOfSize:16];
  116. // _groupPriceLabel.text = @"¥18.80/件";
  117. }
  118. return _groupPriceLabel;
  119. }
  120. - (UILabel *)directTipLabel {
  121. if (!_directTipLabel) {
  122. _directTipLabel = [[UILabel alloc]init];
  123. _directTipLabel.textColor = UIColorFromRGB(0xffffff);
  124. _directTipLabel.textAlignment = NSTextAlignmentCenter;
  125. _directTipLabel.font = [UIFont systemFontOfSize:14];
  126. _directTipLabel.text = @"直接购买";
  127. }
  128. return _directTipLabel;
  129. }
  130. - (UILabel *)directPriceLabel {
  131. if (!_directPriceLabel) {
  132. _directPriceLabel = [[UILabel alloc]init];
  133. _directPriceLabel.textColor = UIColorFromRGB(0xffffff);
  134. _directPriceLabel.textAlignment = NSTextAlignmentCenter;
  135. _directPriceLabel.font = [UIFont systemFontOfSize:16];
  136. // _directPriceLabel.text = @"¥21.80/件";
  137. }
  138. return _directPriceLabel;
  139. }
  140. @end