BottomToolView.m 3.49 KB
//
//  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