CNLiveThirdLoginView.m 2.02 KB
//
//  CNLiveThirdLoginView.m
//  CNLiveScioLive
//
//  Created by Xiaowen Zhang on 2018/9/19.
//  Copyright © 2018年 CNLive. All rights reserved.
//

#import "CNLiveThirdLoginView.h"

@interface CNLiveThirdLoginView()
@property (nonatomic, strong) UILabel *titleLabel;


@end
@implementation CNLiveThirdLoginView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        [self setUpUI];
    }
    return self;
    
}
-(void)setBtns:(NSArray *)btns{
    _btns = btns;
    CGFloat width = MainScreenWidth*1.0/btns.count;
    for(int i = 0; i < btns.count; i++){
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(i*width, 40, width, 60);
        btn.tag = 1000+i;
        btn.layer.masksToBounds = YES;
        [btn setImage:[[UIImage imageNamed:btns[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(clickedLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btn];
        
    }
}
- (void)setUpUI{
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.numberOfLines = 1;
    _titleLabel.textColor = HEXCOLOR(0x333333);
    _titleLabel.font = [UIFont systemFontOfSize:15];
    _titleLabel.text = CustomStr(@"ThirdPartyLogin");
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_titleLabel];
    
}
- (void)layoutSubviews{
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).with.offset(0);
        make.left.equalTo(self.mas_left).with.offset(10);
        make.right.equalTo(self.mas_right).with.offset(-10);
        make.height.offset(30);
        
    }];
    
    
}
- (void)clickedLoginBtn:(UIButton *)btn{
    self.block?self.block(btn.tag):@"";
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end