HomePageSecHeaderView.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // HomePageSecHeaderView.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/9.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "HomePageSecHeaderView.h"
  9. #import "UIView+gesture.h"
  10. #import "HomePageSecHeaderModel.h"
  11. @interface HomePageSecHeaderView ()
  12. @property (nonatomic, readwrite, strong) UIView *contentView;
  13. @property (nonatomic, readwrite, strong) UILabel *rightTitleLabel;
  14. @property (nonatomic, readwrite, strong) UIImageView *arrowImageView;
  15. @property (nonatomic, readwrite, strong) UIImageView *titleIconImageView;
  16. @end
  17. @implementation HomePageSecHeaderView
  18. #pragma mark - Life Cycle
  19. - (instancetype)initWithFrame:(CGRect)frame {
  20. self = [super initWithFrame:frame];
  21. if (self) {
  22. [self addSubview:self.contentView];
  23. [self.contentView addSubview:self.titleIconImageView];
  24. [self.contentView addSubview:self.titleLabel];
  25. [self.contentView addSubview:self.rightTitleLabel];
  26. [self.contentView addSubview:self.arrowImageView];
  27. }
  28. __weak typeof (self) weakS = self;
  29. [self.contentView addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
  30. [weakS clickSelf];
  31. }];
  32. return self;
  33. }
  34. - (void)layoutSubviews {
  35. [super layoutSubviews];
  36. if (![self.subviews containsObject:[self rootView].jxTitle]) {
  37. [self insertSubview:self.rootView.jxTitle atIndex:0];
  38. }
  39. [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.top.right.mas_offset(0);
  41. make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.height * 0.5));
  42. }];
  43. [_titleIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.centerY.mas_equalTo(self.contentView);
  45. make.left.mas_offset(16);
  46. make.size.mas_equalTo(CGSizeMake(5, self.bounds.size.height * 0.2));
  47. }];
  48. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.centerY.mas_equalTo(self.contentView);
  50. make.left.mas_equalTo(_titleIconImageView.mas_right).mas_offset(8);
  51. make.size.mas_equalTo(CGSizeMake(self.bounds.size.width * 0.3, self.bounds.size.height * 0.5));
  52. }];
  53. [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.centerY.mas_equalTo(self.contentView);
  55. make.right.mas_offset(-10);
  56. make.size.mas_equalTo(CGSizeMake((17.0 / 28.0) * self.bounds.size.height * 0.15, self.bounds.size.height * 0.15));
  57. }];
  58. [_rightTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.centerY.mas_equalTo(self.contentView);
  60. make.right.mas_equalTo(_arrowImageView.mas_left).mas_offset(-4);
  61. make.size.mas_equalTo(CGSizeMake(self.bounds.size.width * 0.2, self.bounds.size.height * 0.5));
  62. }];
  63. // [self.rootView.jxTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  64. // make.left.bottom.right.mas_offset(0);
  65. // make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.height * 0.5));
  66. // }];
  67. self.rootView.jxTitle.frame = CGRectMake(0, self.bounds.size.height / 3.0, self.bounds.size.width, self.bounds.size.height / 2.0 + ((self.bounds.size.height / 2.0) - (self.bounds.size.height / 3.0 )));
  68. }
  69. #pragma mark - Private Functions
  70. - (void)updateSecVUI:(__kindof HDSectionModel *)model {
  71. HomePageSecHeaderModel *headerModel = model.headerObj;
  72. _titleLabel.text = @"报名情况";
  73. _rightTitleLabel.text = @"更多";
  74. }
  75. - (void)clickSelf {
  76. self.callback(self.hdSecModel);
  77. }
  78. #pragma mark - LazyLoad
  79. -(UIView *)contentView {
  80. if (!_contentView) {
  81. _contentView = [[UIView alloc] init];
  82. _contentView.backgroundColor = UIColor.whiteColor;
  83. }
  84. return _contentView;
  85. }
  86. - (UILabel *)titleLabel {
  87. if (!_titleLabel) {
  88. _titleLabel = [UILabel new];
  89. _titleLabel.font = [UIFont systemFontOfSize:17];
  90. _titleLabel.textAlignment = NSTextAlignmentLeft;
  91. }
  92. return _titleLabel;
  93. }
  94. - (UILabel *)rightTitleLabel {
  95. if (!_rightTitleLabel) {
  96. _rightTitleLabel = [UILabel new];
  97. _rightTitleLabel.font = [UIFont systemFontOfSize:15];
  98. _rightTitleLabel.textAlignment = NSTextAlignmentRight;
  99. _rightTitleLabel.textColor = UIColor.lightGrayColor;
  100. }
  101. return _rightTitleLabel;
  102. }
  103. - (UIImageView *)titleIconImageView {
  104. if (!_titleIconImageView) {
  105. _titleIconImageView = [[UIImageView alloc] init];
  106. _titleIconImageView.backgroundColor = RQSubColor;
  107. _titleIconImageView.layer.cornerRadius = 2.5;
  108. _titleIconImageView.clipsToBounds = YES;
  109. }
  110. return _titleIconImageView;
  111. }
  112. - (UIImageView *)arrowImageView {
  113. if (!_arrowImageView) {
  114. _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ArrowLight"]];
  115. }
  116. return _arrowImageView;
  117. }
  118. @end