天天省钱快报

KBTaobaoAuthorView.m 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // KBTaobaoAuthorView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/2/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBTaobaoAuthorView.h"
  9. typedef void (^ClickBolck)(void);
  10. @interface KBTaobaoAuthorView ()
  11. @property (nonatomic, strong) UILabel *textLabel;
  12. @property (nonatomic, strong) UIImageView *imgView;
  13. @property (nonatomic, copy) ClickBolck clickBlock;
  14. @end
  15. @implementation KBTaobaoAuthorView
  16. - (instancetype)initWithFrame:(CGRect)frame text:(NSString *)text clickBlock:(void (^)(void))clickBlock{
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.backgroundColor = [UIColor whiteColor];
  20. self.clickBlock = clickBlock;
  21. self.textLabel.text = text;
  22. [self initUI];
  23. }
  24. return self;
  25. }
  26. - (void)initUI {
  27. [self addSubview:self.loginBtn];
  28. [self addSubview:self.textLabel];
  29. [self addSubview:self.imgView];
  30. [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.right.mas_offset(10);
  32. make.centerY.mas_equalTo(self.mas_centerY);
  33. }];
  34. [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.centerX.mas_equalTo(self.mas_centerX);
  36. make.bottom.mas_equalTo(self.textLabel.mas_top).mas_offset(-25);
  37. make.width.height.mas_equalTo(70);
  38. }];
  39. [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.centerX.mas_equalTo(self.mas_centerX);
  41. make.width.mas_equalTo(100);
  42. make.height.mas_equalTo(30);
  43. make.top.mas_equalTo(self.textLabel.mas_bottom).mas_offset(25);
  44. }];
  45. }
  46. - (void)btnClick {
  47. if (self.clickBlock) {
  48. self.clickBlock();
  49. }
  50. }
  51. - (UIButton *)loginBtn {
  52. if (!_loginBtn) {
  53. _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  54. _loginBtn.backgroundColor = [UIColor homeRedColor];
  55. [_loginBtn setTitle:@"立即登录" forState:UIControlStateNormal];
  56. [_loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  57. _loginBtn.titleLabel.font = [UIFont systemFontOfSize:13];
  58. [_loginBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside
  59. ];
  60. }
  61. return _loginBtn;
  62. }
  63. - (UILabel *)textLabel {
  64. if (!_textLabel) {
  65. _textLabel = [[UILabel alloc] init];
  66. _textLabel.textColor = [UIColor YHColorWithHex:0x444444];
  67. _textLabel.font = [UIFont systemFontOfSize:13];
  68. _textLabel.textAlignment = NSTextAlignmentCenter;
  69. }
  70. return _textLabel;
  71. }
  72. - (UIImageView *)imgView {
  73. if (!_imgView) {
  74. _imgView = [[UIImageView alloc] init];
  75. _imgView.image = [UIImage imageNamed:@"noLog"];
  76. }
  77. return _imgView;
  78. }
  79. @end