123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- //
- // FKDetailGroupBuyCell.m
- // FirstLink
- //
- // Created by ascii on 15/10/8.
- // Copyright © 2015年 FirstLink. All rights reserved.
- //
- #import "FKDetailGroupBuyView.h"
- @interface FKDetailGroupBuyView ()
- @property (nonatomic, strong) UILabel *groupPriceLabel;
- @property (nonatomic, strong) UILabel *groupTipLabel;
- @property (nonatomic, strong) UILabel *directPriceLabel;
- @property (nonatomic, strong) UILabel *directTipLabel;
- @end
- @implementation FKDetailGroupBuyView
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- #pragma mark - Function
- + (CGFloat)height {
- return 60;
- }
- - (void)configUIForTip {
- [self removeAllSubviews];
-
- self.textColor = UIColorFromRGB(0xffffff);
- self.backgroundColor = UIColorFromRGB(0xfcbf4a);
- self.textAlignment = NSTextAlignmentCenter;
- self.font = [UIFont systemFontOfSize:16];
- self.text = @"本次活动已结束,去看看其它商品";
- }
- - (void)configUIForBuy:(NSString *)normalPrice groupPrice:(NSString *)groupPrice {
- [self addAllSubviewsForBuy:normalPrice
- groupPrice:groupPrice];
- }
- #pragma mark - Method
- - (void)removeAllSubviews {
- [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- [obj removeFromSuperview];
- }];
- }
- - (void)addAllSubviewsForBuy:(NSString *)normalPrice groupPrice:(NSString *)groupPrice {
- [self removeAllSubviews];
-
- self.groupPriceLabel.text = groupPrice;
- self.directPriceLabel.text = normalPrice;
-
- WeakSelf(weakSelf);
- [self addSubview:self.groupBuyButton];
- [self.groupBuyButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.top.bottom.equalTo(weakSelf);
- }];
-
- [self addSubview:self.directBuyButton];
- [self.directBuyButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.equalTo(weakSelf);
- make.right.mas_equalTo(weakSelf.groupBuyButton.mas_left);
- make.width.mas_equalTo(weakSelf.groupBuyButton.mas_width);
- }];
-
- [self.groupBuyButton addSubview:self.groupTipLabel];
- [self.groupTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(weakSelf.groupBuyButton);
- make.bottom.equalTo(weakSelf.groupBuyButton).offset(-11);
- make.height.mas_equalTo(18);
- }];
-
- [self.groupBuyButton addSubview:self.groupPriceLabel];
- [self.groupPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(weakSelf.groupBuyButton);
- make.bottom.equalTo(weakSelf.groupTipLabel.mas_top);
- make.height.mas_equalTo(20);
- }];
-
- [self.directBuyButton addSubview:self.directTipLabel];
- [self.directTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(weakSelf.directBuyButton);
- make.bottom.equalTo(weakSelf.directBuyButton).offset(-11);
- make.height.mas_equalTo(18);
- }];
-
- [self.directBuyButton addSubview:self.directPriceLabel];
- [self.directPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(weakSelf.directBuyButton);
- make.bottom.equalTo(weakSelf.directTipLabel.mas_top);
- make.height.mas_equalTo(20);
- }];
- }
- #pragma mark - Property
- - (UIButton *)groupBuyButton {
- if (!_groupBuyButton) {
- _groupBuyButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _groupBuyButton.backgroundColor = UIColorFromRGB(0x00c8a9);
- }
- return _groupBuyButton;
- }
- - (UIButton *)directBuyButton {
- if (!_directBuyButton) {
- _directBuyButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _directBuyButton.backgroundColor = [UIColor colorWithWhite:0 alpha:1];
- }
- return _directBuyButton;
- }
- - (UILabel *)groupTipLabel {
- if (!_groupTipLabel) {
- _groupTipLabel = [[UILabel alloc]init];
- _groupTipLabel.textColor = UIColorFromRGB(0xffffff);
- _groupTipLabel.textAlignment = NSTextAlignmentCenter;
- _groupTipLabel.font = [UIFont systemFontOfSize:14];
- _groupTipLabel.text = @"成为团长并开团";
- }
- return _groupTipLabel;
- }
- - (UILabel *)groupPriceLabel {
- if (!_groupPriceLabel) {
- _groupPriceLabel = [[UILabel alloc]init];
- _groupPriceLabel.textColor = UIColorFromRGB(0xffffff);
- _groupPriceLabel.textAlignment = NSTextAlignmentCenter;
- _groupPriceLabel.font = [UIFont systemFontOfSize:16];
- // _groupPriceLabel.text = @"¥18.80/件";
- }
- return _groupPriceLabel;
- }
- - (UILabel *)directTipLabel {
- if (!_directTipLabel) {
- _directTipLabel = [[UILabel alloc]init];
- _directTipLabel.textColor = UIColorFromRGB(0xffffff);
- _directTipLabel.textAlignment = NSTextAlignmentCenter;
- _directTipLabel.font = [UIFont systemFontOfSize:14];
- _directTipLabel.text = @"直接购买";
- }
- return _directTipLabel;
- }
- - (UILabel *)directPriceLabel {
- if (!_directPriceLabel) {
- _directPriceLabel = [[UILabel alloc]init];
- _directPriceLabel.textColor = UIColorFromRGB(0xffffff);
- _directPriceLabel.textAlignment = NSTextAlignmentCenter;
- _directPriceLabel.font = [UIFont systemFontOfSize:16];
- // _directPriceLabel.text = @"¥21.80/件";
- }
- return _directPriceLabel;
- }
- @end
|