// // DRTaobaoAuthorView.m // YouHuiProject // // Created by 小花 on 2018/2/6. // Copyright © 2018年 kuxuan. All rights reserved. // #import "DRTaobaoAuthorView.h" typedef void (^ClickBolck)(void); @interface DRTaobaoAuthorView () @property (nonatomic, strong) UILabel *textLabel; @property (nonatomic, strong) UIImageView *imgView; @property (nonatomic, copy) ClickBolck clickBlock; @end @implementation DRTaobaoAuthorView - (instancetype)initWithFrame:(CGRect)frame text:(NSString *)text clickBlock:(void (^)(void))clickBlock{ self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; self.clickBlock = clickBlock; self.textLabel.text = text; [self initUI]; } return self; } - (void)initUI { [self addSubview:self.loginBtn]; [self addSubview:self.textLabel]; [self addSubview:self.imgView]; [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_offset(10); make.centerY.mas_equalTo(self.mas_centerY); }]; [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.mas_centerX); make.bottom.mas_equalTo(self.textLabel.mas_top).mas_offset(-25); make.width.height.mas_equalTo(70); }]; [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.mas_centerX); make.width.mas_equalTo(100); make.height.mas_equalTo(30); make.top.mas_equalTo(self.textLabel.mas_bottom).mas_offset(25); }]; } - (void)btnClick { if (self.clickBlock) { self.clickBlock(); } } - (UIButton *)loginBtn { if (!_loginBtn) { _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _loginBtn.backgroundColor = [UIColor homeRedColor]; [_loginBtn setTitle:@"立即登录" forState:UIControlStateNormal]; [_loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; _loginBtn.titleLabel.font = [UIFont systemFontOfSize:13]; [_loginBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside ]; } return _loginBtn; } - (UILabel *)textLabel { if (!_textLabel) { _textLabel = [[UILabel alloc] init]; _textLabel.textColor = [UIColor YHColorWithHex:0x444444]; _textLabel.font = [UIFont systemFontOfSize:13]; _textLabel.textAlignment = NSTextAlignmentCenter; } return _textLabel; } - (UIImageView *)imgView { if (!_imgView) { _imgView = [[UIImageView alloc] init]; _imgView.image = [UIImage imageNamed:@"noLog"]; } return _imgView; } @end