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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// KWMCarCountView.m
// iCemarose
//
// Created by 陈荣科 on 16/9/23.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMCarCountView.h"
#import "KWMShopCartData.h"
@implementation KWMCarCountView
- (instancetype)init{
if (self=[super init]) {
[self initContentView];
}
return self;
}
- (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)awakeFromNib{
[super awakeFromNib];
[self initContentView];
}
- (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";
}
}
- (IBAction)onClickShopCartBtn:(id)sender {
NSLog(@"点击了购物车");
if (self.delegate != nil) {
[self.delegate kwm_touchShopCartBtn];
}
}
@end