LoginRecomFooterCollectReusView.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // LoginRecomFooterCollectReusView.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/12/11.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "LoginRecomFooterCollectReusView.h"
  9. @interface LoginRecomFooterCollectReusView ()
  10. @property(nonatomic, strong) QMUIButton *changeBtn;
  11. @property(nonatomic, strong) QMUIButton *goBtn;
  12. @end
  13. static NSString *const image_name_change = @"lr换一批";
  14. static NSString *const image_name_go = @"lr进入按钮";
  15. @implementation LoginRecomFooterCollectReusView
  16. - (instancetype)initWithFrame:(CGRect)frame
  17. {
  18. self = [super initWithFrame:frame];
  19. if (self) {
  20. [self initUI];
  21. }
  22. return self;
  23. }
  24. - (void)initUI{
  25. _changeBtn = ({
  26. QMUIButton * btn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  27. [btn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
  28. btn.titleLabel.font = [UIFont systemFontOfSize:16];
  29. [btn setTitle:ASLocalizedString(@"换一批")forState:UIControlStateNormal];
  30. [btn setImage:[UIImage imageNamed:image_name_change] forState:UIControlStateNormal];
  31. btn.imagePosition = QMUIButtonImagePositionLeft;
  32. btn.spacingBetweenImageAndTitle = 2;
  33. [btn addTarget:self action:@selector(changeAction) forControlEvents:UIControlEventTouchUpInside];
  34. btn;
  35. });
  36. _goBtn = ({
  37. QMUIButton * btn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  38. [btn setTitleColor:kWhiteColor forState:UIControlStateNormal];
  39. btn.titleLabel.font = [UIFont systemFontOfSize:13];
  40. [btn setTitle:ASLocalizedString(@"点击进入")forState:UIControlStateNormal];
  41. [btn setBackgroundImage:[UIImage imageNamed:image_name_go] forState:UIControlStateNormal];
  42. [btn addTarget:self action:@selector(goAction) forControlEvents:UIControlEventTouchUpInside];
  43. btn;
  44. });
  45. [self addSubview:_changeBtn];
  46. [self addSubview:_goBtn];
  47. }
  48. - (void)changeAction {
  49. if (self.changeBlock) {
  50. self.changeBlock();
  51. }
  52. }
  53. - (void)goAction {
  54. if (self.goBlock) {
  55. self.goBlock();
  56. }
  57. }
  58. - (void)layoutSubviews {
  59. [super layoutSubviews];
  60. [_changeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.mas_equalTo(30);
  62. make.centerX.mas_equalTo(0);
  63. make.left.mas_equalTo(0);
  64. }];
  65. [_goBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.bottom.mas_equalTo(-10);
  67. make.centerX.mas_equalTo(0);
  68. make.width.mas_equalTo(200);
  69. make.height.mas_equalTo(44);
  70. }];
  71. }
  72. @end