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

DRBuyLimitHeader.m 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // DRBuyLimitHeader.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/9.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRBuyLimitHeader.h"
  9. #import "DRBuyLimitGoodView.h"
  10. @interface DRBuyLimitHeader (){
  11. UILabel *_title;
  12. }
  13. @property (nonatomic, strong) DRBuyLimitGoodView *limitGoodView;
  14. @end
  15. @implementation DRBuyLimitHeader
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. [self initSubView];
  20. }
  21. return self;
  22. }
  23. - (void)initSubView {
  24. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 116)];
  25. bgView.backgroundColor = [UIColor YHColorWithHex:0x3F3D39];
  26. [self addSubview:bgView];
  27. UIView *cardView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, self.width-30, 156)];
  28. cardView.backgroundColor = [UIColor whiteColor];
  29. cardView.layer.cornerRadius = 8;
  30. cardView.layer.shadowColor = [UIColor blackColor].CGColor;
  31. cardView.layer.shadowOffset = CGSizeMake(2, 5);
  32. cardView.layer.shadowOpacity = 0.3;
  33. cardView.layer.shadowRadius = 3;
  34. [self addSubview:cardView];
  35. UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 13, 16, 16)];
  36. icon.image = [UIImage imageNamed:@"willKong"];
  37. [cardView addSubview:icon];
  38. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(icon.right+3, 5, 200, 33)];
  39. title.text = @"即将售空";
  40. title.textColor = [UIColor YHColorWithHex:0xFF5000];
  41. title.font = [UIFont systemFontOfSize:14];
  42. [cardView addSubview:title];
  43. _title = title;
  44. self.limitGoodView = [[DRBuyLimitGoodView alloc] initWithFrame:CGRectMake(10, 42, cardView.width-20, 94)];
  45. [cardView addSubview:self.limitGoodView];
  46. UIView *gesView = [[UIView alloc] initWithFrame:self.bounds];
  47. gesView.backgroundColor = [UIColor clearColor];
  48. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
  49. gesView.backgroundColor = [UIColor clearColor];
  50. [gesView addGestureRecognizer:tap];
  51. [self addSubview:gesView];
  52. }
  53. - (void)tapAction {
  54. if (!self.canBuy) {
  55. [MBProgressHUD showMessage:@"抢购还未开始"];
  56. return;
  57. }
  58. if (self.ClickBlock && _model) {
  59. self.ClickBlock(_model);
  60. }
  61. }
  62. - (void)setModel:(DRBuyLimitGoodModel *)model {
  63. _model = model;
  64. [self.limitGoodView setModel:model];
  65. }
  66. - (void)setCanBuy:(BOOL)canBuy {
  67. _canBuy = canBuy;
  68. NSString *title = canBuy?@"即将售空":@"热门关注";
  69. _title.text = title;
  70. self.limitGoodView.buyButton.enabled = canBuy;
  71. UIColor *color = canBuy?[UIColor homeRedColor]:[UIColor lightGrayColor];
  72. self.limitGoodView.buyButton.backgroundColor = color;
  73. }
  74. @end