//
//  LeftSubView.m
//  Lighting
//
//  Created by mac on 16/5/10.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "LeftSubView.h"

@implementation LeftSubView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self initdata];
        [self initSubView];
    }
    return self;
}
-(void)initdata
{
    self.dataArray=[[NSMutableArray alloc]initWithObjects:@"返回",@"购物车",@"分享",@"自定义场景",@"全屏",@"帮助", nil];
}
-(void)initSubView
{
    for (int i=0; i<self.dataArray.count; i++) {
        UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
        button.tag=100+i;
        button.frame=CGRectMake(30, 30+(60 +15)*i, 60, 60);
        [button addTarget:self action:@selector(leftBtnDidSelected:) forControlEvents:UIControlEventTouchUpInside];
        switch (i) {
            case 0:
                [button setBackgroundImage:[UIImage imageNamed:@"reBackBtn"] forState:UIControlStateNormal];
                
                break;
            case 1:
                [button setBackgroundImage:[UIImage imageNamed:@"gouwuche"] forState:UIControlStateNormal];
                
                break;
            case 2:
                [button setBackgroundImage:[UIImage imageNamed:@"fenxiang"] forState:UIControlStateNormal];
                
                break;
            case 3:
                [button setBackgroundImage:[UIImage imageNamed:@"customchangjing"] forState:UIControlStateNormal];
                
                break;
            case 4:
                [button setBackgroundImage:[UIImage imageNamed:@"quanping"] forState:UIControlStateNormal];
                
                break;
            case 5:
                [button setBackgroundImage:[UIImage imageNamed:@"bangzhu"] forState:UIControlStateNormal];
                
                break;
                
            default:
                break;
        }
        [self addSubview:button];
    }
    
}
-(void)leftBtnDidSelected:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(buttonClick:withButton:)]) {
        
        [self.delegate buttonClick:sender.tag withButton:sender];
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
