TrainSituationNumHeaderView.m 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // TrainSituationNumHeaderView.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/17.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "TrainSituationNumHeaderView.h"
  9. #import "TrainSituationNumHeaderModel.h"
  10. @interface TrainSituationNumHeaderView ()
  11. @property (nonatomic, readwrite, strong) UIButton *signUpNumBtn;
  12. @property (nonatomic, readwrite, strong) UIButton *trainNumBtn;
  13. @end
  14. @implementation TrainSituationNumHeaderView
  15. #pragma mark - Life Cycle
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.backgroundColor = UIColor.whiteColor;
  20. [self addSubview:self.signUpNumBtn];
  21. [self addSubview:self.trainNumBtn];
  22. }
  23. return self;
  24. }
  25. - (void)layoutSubviews {
  26. [super layoutSubviews];
  27. [_signUpNumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.mas_offset(24);
  29. make.centerY.mas_equalTo(self);
  30. make.size.mas_equalTo(CGSizeMake((kScreenWidth - 72) / 2.f, self.bounds.size.height * 0.6));
  31. _signUpNumBtn.layer.cornerRadius = self.bounds.size.height * 0.3;
  32. }];
  33. [_trainNumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.mas_equalTo(_signUpNumBtn.mas_right).mas_offset(24);
  35. make.centerY.mas_equalTo(self);
  36. make.size.mas_equalTo(CGSizeMake((kScreenWidth - 72) / 2.f, self.bounds.size.height * 0.6));
  37. _trainNumBtn.layer.cornerRadius = self.bounds.size.height * 0.3;
  38. }];
  39. }
  40. #pragma mark - Private Functions
  41. - (void)updateSecVUI:(__kindof HDSectionModel *)model {
  42. TrainSituationNumHeaderModel *headerModel = model.headerObj;
  43. _signUpNumBtn.hidden = !headerModel.leftLabelText;
  44. _trainNumBtn.hidden = !headerModel.rightLabelText;
  45. [_signUpNumBtn setTitle:headerModel.leftLabelText? : @"" forState:UIControlStateNormal];
  46. [_trainNumBtn setTitle:headerModel.rightLabelText? : @"" forState:UIControlStateNormal];
  47. }
  48. #pragma mark - LazyLoad
  49. - (UIButton *)signUpNumBtn {
  50. if (!_signUpNumBtn) {
  51. _signUpNumBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  52. [_signUpNumBtn setTitle:@"" forState:UIControlStateNormal];
  53. _signUpNumBtn.titleLabel.font = [UIFont systemFontOfSize:13];
  54. _signUpNumBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
  55. _signUpNumBtn.titleLabel.textColor = UIColor.whiteColor;
  56. _signUpNumBtn.backgroundColor = RQPinkBlueColor;
  57. _signUpNumBtn.clipsToBounds = YES;
  58. }
  59. return _signUpNumBtn;
  60. }
  61. - (UIButton *)trainNumBtn {
  62. if (!_trainNumBtn) {
  63. _trainNumBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  64. [_trainNumBtn setTitle:@"" forState:UIControlStateNormal];
  65. _trainNumBtn.titleLabel.font = [UIFont systemFontOfSize:13];
  66. _trainNumBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
  67. _trainNumBtn.titleLabel.textColor = UIColor.whiteColor;
  68. _trainNumBtn.backgroundColor = RQPinkGreenColor;
  69. _trainNumBtn.clipsToBounds = YES;
  70. }
  71. return _trainNumBtn;
  72. }
  73. @end