KWMCarCountView.m 1.49 KB
Newer Older
houweibin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
//
//  KWMCarCountView.m
//  iCemarose
//
//  Created by 陈荣科 on 16/9/23.
//  Copyright © 2016年 kollway. All rights reserved.
//

#import "KWMCarCountView.h"
#import "KWMShopCartData.h"

@implementation KWMCarCountView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        [self initContentView];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self=[super initWithCoder:aDecoder]) {
        [self initContentView];
    }
    return self;
}

- (void) initContentView{
    [[NSBundle mainBundle] loadNibNamed:@"KWMCarCountView" owner:self options:nil];
    self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    [self addSubview:self.vContent];
    _lbCount.text = @"0";
    self.lbCount.userInteractionEnabled = NO;
}

-(void)setCount:(NSInteger)count{
    _count = count;
    if (count>0) {
        _lbCount.text = [NSString stringWithFormat:@"%ld",count];
        if (count > 9) {
            _lbCount.font = [UIFont systemFontOfSize:8];
        }
    }else{
        _lbCount.text = @"0";
    }
}

houweibin committed
48 49 50 51 52 53
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
}

houweibin committed
54 55 56 57 58 59
- (IBAction)onClickShopCartBtn:(id)sender {
    NSLog(@"点击了购物车");
    if (self.delegate != nil) {
        [self.delegate kwm_touchShopCartBtn];
    }
}
lee committed
60 61 62 63

- (void)onClickSearchBtn:(id)sender {
    [self.delegate kwm_touchSearchBtn];
}
houweibin committed
64
@end