// // KBBuyLimitGoodCell.m // YouHuiProject // // Created by 小花 on 2018/7/9. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBBuyLimitGoodCell.h" #import "KBBuyLimitGoodView.h" @interface KBBuyLimitGoodCell () @property (nonatomic, strong) KBBuyLimitGoodView *limitGoodView; @end @implementation KBBuyLimitGoodCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); KBBuyLimitGoodCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[KBBuyLimitGoodCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initSubViews]; } return self; } - (void)initSubViews { [self.contentView addSubview:self.limitGoodView]; [self.limitGoodView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(25); make.right.mas_equalTo(-25); make.top.mas_equalTo(15); make.height.mas_equalTo(94); }]; } - (void)setModel:(KBBuyLimitGoodModel *)model { _model = model; self.limitGoodView.model = model; } - (void)setCanBuy:(BOOL)canBuy { _canBuy = canBuy; self.limitGoodView.buyButton.enabled = canBuy; UIColor *color = canBuy?[UIColor homeRedColor]:[UIColor lightGrayColor]; self.limitGoodView.buyButton.backgroundColor = color; } - (KBBuyLimitGoodView *)limitGoodView { if (!_limitGoodView) { _limitGoodView = [[KBBuyLimitGoodView alloc] init]; } return _limitGoodView; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end