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
//
// 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