// // 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"; } } - (void)layoutSubviews { [super layoutSubviews]; self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); } - (IBAction)onClickShopCartBtn:(id)sender { NSLog(@"点击了购物车"); if (self.delegate != nil) { [self.delegate kwm_touchShopCartBtn]; } } - (void)onClickSearchBtn:(id)sender { [self.delegate kwm_touchSearchBtn]; } @end