1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- //
- // DRBuyLimitHeader.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/9.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRBuyLimitHeader.h"
- #import "DRBuyLimitGoodView.h"
- @interface DRBuyLimitHeader (){
- UILabel *_title;
- }
- @property (nonatomic, strong) DRBuyLimitGoodView *limitGoodView;
- @end
- @implementation DRBuyLimitHeader
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubView];
- }
- return self;
- }
- - (void)initSubView {
-
- UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 116)];
- bgView.backgroundColor = [UIColor YHColorWithHex:0x3F3D39];
- [self addSubview:bgView];
-
- UIView *cardView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, self.width-30, 156)];
- cardView.backgroundColor = [UIColor whiteColor];
- cardView.layer.cornerRadius = 8;
- cardView.layer.shadowColor = [UIColor blackColor].CGColor;
- cardView.layer.shadowOffset = CGSizeMake(2, 5);
- cardView.layer.shadowOpacity = 0.3;
- cardView.layer.shadowRadius = 3;
- [self addSubview:cardView];
-
- UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 13, 16, 16)];
- icon.image = [UIImage imageNamed:@"willKong"];
- [cardView addSubview:icon];
-
- UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(icon.right+3, 5, 200, 33)];
- title.text = @"即将售空";
- title.textColor = [UIColor YHColorWithHex:0xFF5000];
- title.font = [UIFont systemFontOfSize:14];
- [cardView addSubview:title];
- _title = title;
-
- self.limitGoodView = [[DRBuyLimitGoodView alloc] initWithFrame:CGRectMake(10, 42, cardView.width-20, 94)];
- [cardView addSubview:self.limitGoodView];
-
- UIView *gesView = [[UIView alloc] initWithFrame:self.bounds];
- gesView.backgroundColor = [UIColor clearColor];
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
- gesView.backgroundColor = [UIColor clearColor];
- [gesView addGestureRecognizer:tap];
- [self addSubview:gesView];
- }
- - (void)tapAction {
- if (!self.canBuy) {
- [MBProgressHUD showMessage:@"抢购还未开始"];
- return;
- }
-
-
- if (self.ClickBlock && _model) {
- self.ClickBlock(_model);
- }
- }
- - (void)setModel:(DRBuyLimitGoodModel *)model {
- _model = model;
- [self.limitGoodView setModel:model];
- }
- - (void)setCanBuy:(BOOL)canBuy {
- _canBuy = canBuy;
- NSString *title = canBuy?@"即将售空":@"热门关注";
- _title.text = title;
- self.limitGoodView.buyButton.enabled = canBuy;
- UIColor *color = canBuy?[UIColor homeRedColor]:[UIColor lightGrayColor];
- self.limitGoodView.buyButton.backgroundColor = color;
- }
- @end
|