LeftSubView.m 1.4 KB
//
//  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, 100, 60);
        [button setTitle:[self.dataArray objectAtIndex:i] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(leftBtnDidSelected:) forControlEvents:UIControlEventTouchUpInside];
        [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