//
//  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];
     self.helpArray=[[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];
                self.fanHuiBtn=button;//返回
              
//        UIView *view=[[UIView alloc]initWithFrame:CGRectMake(100, 30+(60 +15)*i+10, 100, 40)];
//                view.backgroundColor=[UIColor whiteColor];
//                UILabel *lable=
//            [self addSubview:view];
            }
                break;
            case 1:
                [button setBackgroundImage:[UIImage imageNamed:@"gouwuche"] forState:UIControlStateNormal];
               self.shoppingBtn=button;//购物车
              
                break;
            case 2:
                [button setBackgroundImage:[UIImage imageNamed:@"fenxiang"] forState:UIControlStateNormal];
                self.shareBtn=button;//分享
                
                break;
            case 3:
                [button setBackgroundImage:[UIImage imageNamed:@"customchangjing"] forState:UIControlStateNormal];
                self.camerBtn=button;//自定义场景
              
                break;
            case 4:
                [button setBackgroundImage:[UIImage imageNamed:@"quanping"] forState:UIControlStateNormal];
               self.fullViewBtn=button;//全屏
               
                break;
            case 5:
                [button setBackgroundImage:[UIImage imageNamed:@"bangzhu"] forState:UIControlStateNormal];
                 self.helpBtn=button;//帮助
                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
