ThirdPartyView.m 4.63 KB
//
//  ThirdPartyView.m
//  CNLiveUserSystemDemo
//
//  Created by iOS on 16/11/18.
//  Copyright © 2016年 zhulin. All rights reserved.
//

#import "ThirdPartyView.h"

#define SpaceWidth (KScreenWidth-80*3)/4
@interface ThirdPartyView ()

@property (nonatomic, strong) UIButton *weChatBtn;
@property (nonatomic, strong) UIButton *sinaBtn;
@property (nonatomic, strong) UIButton *qqBtn;
@property (nonatomic, strong) UILabel *thirdpartyLoginLbl;
@property (nonatomic, strong) UIButton *cancelBtn;

@end

@implementation ThirdPartyView

- (instancetype)initWithFrame:(CGRect)frame binding:(BOOL)binding
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.sinaBtn];
        [self addSubview:self.qqBtn];
        [self addSubview:self.weChatBtn];
        [self addSubview:self.thirdpartyLoginLbl];
        
        if (binding) {
            [self addSubview:self.cancelBtn];
        }
    }
    return self;
}

#pragma mark - ****************action******
- (void)thirdPartyBtnAction:(UIButton *)button
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(thirdPartyBtnAction:)]) {
        [self.delegate thirdPartyBtnAction:button.titleLabel.text];
    }
}

- (void)cancelBtnAction
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(cancelThirdView)]) {
        [self.delegate cancelThirdView];
    }
}

#pragma mark - ****************getter******

- (UILabel *)thirdpartyLoginLbl
{
    if (!_thirdpartyLoginLbl) {
        _thirdpartyLoginLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, KScreenWidth, 15)];
        _thirdpartyLoginLbl.textAlignment = NSTextAlignmentCenter;
        _thirdpartyLoginLbl.textColor = [UIColor blackColor];
        _thirdpartyLoginLbl.text = @"第三方平台";
        _thirdpartyLoginLbl.font = [UIFont systemFontOfSize:15];
    }
    return _thirdpartyLoginLbl;
}

- (UIButton *)weChatBtn
{
    if (!_weChatBtn) {
        _weChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_weChatBtn setFrame:CGRectMake(SpaceWidth, 70, 80, 40)];
        [_weChatBtn setTitle:@"微信" forState:UIControlStateNormal];
        [_weChatBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        _weChatBtn.titleLabel.font = [UIFont systemFontOfSize:18];
        [_weChatBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
        _weChatBtn.layer.cornerRadius = 20;
        _weChatBtn.layer.masksToBounds = YES;
        _weChatBtn.layer.borderColor = [UIColor blackColor].CGColor;
        _weChatBtn.layer.borderWidth = 1;
    }
    return _weChatBtn;
}

- (UIButton *)sinaBtn
{
    if (!_sinaBtn) {
        _sinaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sinaBtn setFrame:CGRectMake(SpaceWidth*2+80, 70, 80, 40)];
        [_sinaBtn setTitle:@"微博" forState:UIControlStateNormal];
        [_sinaBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        _sinaBtn.titleLabel.font = [UIFont systemFontOfSize:18];
        [_sinaBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
        _sinaBtn.layer.cornerRadius = 20;
        _sinaBtn.layer.masksToBounds = YES;
        _sinaBtn.layer.borderColor = [UIColor blackColor].CGColor;
        _sinaBtn.layer.borderWidth = 1;
    }
    return _sinaBtn;
}

- (UIButton *)qqBtn
{
    if (!_qqBtn) {
        _qqBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_qqBtn setFrame:CGRectMake(SpaceWidth*3+80*2, 70, 80, 40)];
        [_qqBtn setTitle:@"QQ" forState:UIControlStateNormal];
        [_qqBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        _qqBtn.titleLabel.font = [UIFont systemFontOfSize:18];
        [_qqBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
        _qqBtn.layer.cornerRadius = 20;
        _qqBtn.layer.masksToBounds = YES;
        _qqBtn.layer.borderColor = [UIColor blackColor].CGColor;
        _qqBtn.layer.borderWidth = 1;
    }
    return _qqBtn;
}

- (UIButton *)cancelBtn
{
    if (!_cancelBtn) {
        _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cancelBtn.frame = CGRectMake(self.bounds.size.width-30, 10, 20, 20);
        [_cancelBtn setBackgroundImage:[UIImage imageNamed:@"cancel"] forState:UIControlStateNormal];
        [_cancelBtn addTarget:self action:@selector(cancelBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancelBtn;
}

@end