BottomToolView.m
3.49 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
// BottomToolView.m
// LiveVideoCloud
//
// Created by 张旭 on 2017/3/14.
// Copyright © 2017年 cnlive. All rights reserved.
//
#import "BottomToolView.h"
@interface BottomToolView ()
@property (nonatomic ,strong) UIImageView * _Nullable bgView;
@end
@implementation BottomToolView
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self addSubview:self.bgView];
[self addSubview:self.chatBtn];
// [self addSubview:self.privateChatBtn];
[self addSubview:self.giftBtn];
}
return self;
}
#pragma mark - buttonClick
- (void)chatAction
{
if ([self.delegate respondsToSelector:@selector(bottomActionWithType:button:)]) {
[self.delegate bottomActionWithType:BtnClickTypeChat button:self.chatBtn];
}
}
- (void)privateChatAction
{
if ([self.delegate respondsToSelector:@selector(bottomActionWithType:button:)]) {
[self.delegate bottomActionWithType:BtnClickTypePriChat button:self.privateChatBtn];
}
}
- (void)giftAction
{
if ([self.delegate respondsToSelector:@selector(bottomActionWithType:button:)]) {
[self.delegate bottomActionWithType:BtnClickTypeGift button:self.giftBtn];
}
}
- (UIImageView *)bgView
{
if (!_bgView)
{
_bgView = [[UIImageView alloc] initWithFrame:self.bounds];
_bgView.image = [UIImage imageNamed:@"背景400x60"];
}
return _bgView;
}
#pragma mark - getter
- (UIButton *)chatBtn
{
if (!_chatBtn)
{
UIButton *chatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
chatBtn.frame = CGRectMake(30, (self.height - 45)*0.5, 45, 45);
[chatBtn setBackgroundImage:[UIImage imageNamed:@"LiveChatNormal"] forState:UIControlStateNormal];
[chatBtn setBackgroundImage:[UIImage imageNamed:@"LiveChatTouch"] forState:UIControlStateHighlighted];
[chatBtn addTarget:self action:@selector(chatAction) forControlEvents:UIControlEventTouchUpInside];
_chatBtn = chatBtn;
}
return _chatBtn;
}
- (UIButton *)privateChatBtn
{
if (!_privateChatBtn)
{
UIButton *privateChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
privateChatBtn.frame = CGRectMake(self.width*0.5 - 50, (self.height - 45)*0.5, 45, 45);
//[UIColor colorWithRed:0.61 green:0.61 blue:0.61 alpha:1.00]
[privateChatBtn setBackgroundImage:[UIImage imageNamed:@"22"] forState:UIControlStateNormal];
[privateChatBtn setBackgroundImage:[UIImage imageNamed:@"22"] forState:UIControlStateHighlighted];
[privateChatBtn addTarget:self action:@selector(privateChatAction) forControlEvents:UIControlEventTouchUpInside];
_privateChatBtn = privateChatBtn;
}
return _privateChatBtn;
}
- (UIButton *)giftBtn
{
if (!_giftBtn)
{
UIButton *giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
giftBtn.frame = CGRectMake(self.width*0.5 + 10, (self.height - 45)*0.5, 45, 45);
[giftBtn setBackgroundImage:[UIImage imageNamed:@"LiveChatGiftNormal"] forState:UIControlStateNormal];
[giftBtn setBackgroundImage:[UIImage imageNamed:@"LiveChatGiftTouch"] forState:UIControlStateHighlighted];
[giftBtn addTarget:self action:@selector(giftAction) forControlEvents:UIControlEventTouchUpInside];
_giftBtn = giftBtn;
}
return _giftBtn;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end